Terry Riegel wrote:
> ...I would prefer to not have the id in the form. If I remove it the
> dollar function doesn't work anymore (for obvious reasons) is there
> another way to grab the object?
>
> I would rather code it as...
> <input type="text" name="mycomment">
> ...
>
Hi Terry,
I also avoid putting ids onto inputs since they can be accessed through
the forms and elements collections:
document.forms['FormName'].elements['InputName'];
or
document.FormName.elements['InputName'];
In fact, I use a custom function (below) as shorthand:
SF('FormName','InputName');
-- Ken Snyder
//
// SmartForm Function
// returns form object or element object from form name, element name
//
// Example Usage:
// Field(0,'myelement') returns form 0 element "myelement"
// Field('myform','myelement') returns form "myform" element "myelement"
// Field(0) returns form form 0
// Field('myform') returns form "myform" assuming there is no element
named "myform"
// Field('myelement') returns form "myelement" assuming there is no form
named "myelement"
function SF(formName,elName) {
if( elName && document.forms[formName] &&
document.forms[formName].elements ) {
return document.forms[formName].elements[elName];
} else {
return document.forms[formName];
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---