[Greasemonkey] Refrencing a field name without form name

Vectorspace vectorspace at ntlworld.com
Mon Sep 18 09:04:06 EDT 2006


getElementById('fieldname') will return the field element, not the form

rejectpenguin wrote:
> Thanks for your help.
>
> So if I use getelementbyid it will return the form?
>
> So I could use something like:
>
> var formname = getElementById('fieldname');
>
> would this work?
>
>
> Rod McGuire wrote:
>   
>> Quoting rejectpenguin <rejectpenguin at gmail.com>:
>>     
>>> Yeah thats my question.. Is it possible to refrence a javascript field
>>> name
>>> without the form name.
>>>
>>> Example normally I would refrence it like this:
>>> document.form.fieldname.value = "100";
>>>
>>> but what if there is no form name?
>>>       
>> Please read http://www.oreillynet.com/lpt/a/6257
>> All of it, but especially see Pitfall #3:
>>
>> Most people attach an 'id="fieldIDxxx"' onto the field, and then access it
>> by
>> .getElementById('fieldIDxxx') or use XPath.
>>
>>
>> _______________________________________________
>> Greasemonkey mailing list
>> Greasemonkey at mozdev.org
>> http://mozdev.org/mailman/listinfo/greasemonkey
>>
>>
>>     
>
>   


More information about the Greasemonkey mailing list