Thanks Ken,

I am also in the habit of not naming my forms. So this solution would  
involve naming the forms. Something I have done in the past. It seems  
to me this would be common for someone to want to $() a form element,  
but alas I hear no other solutions.

I have another question while were on the topic of forms.

I am building my parameters to pass to my ajax request like...

var pars = '?ajaxrequest='+$F('mycomment');

And it "mostly" works. How would I urlencode $F('mycomment')?

Thanks for any help

Terry




On Jun 7, 2007, at 1:28 PM, Ken Snyder wrote:

>
> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to