Connecting Tech Pros Worldwide Forums | Help | Site Map

getElementByFormVaribleName?

yawnmoth
Guest
 
Posts: n/a
#1: Oct 20 '06
It's easy enough to get elements by their id (getElementById) or by
their type (getElementsByTagName). What about doing so for form
variable names? How might one go about getting the element(s)
associated with document.forms[0].varname?


Martin Honnen
Guest
 
Posts: n/a
#2: Oct 20 '06

re: getElementByFormVaribleName?


yawnmoth wrote:
Quote:
It's easy enough to get elements by their id (getElementById) or by
their type (getElementsByTagName). What about doing so for form
variable names? How might one go about getting the element(s)
associated with document.forms[0].varname?
>
document.forms['formname']
gives you the HTML form element(s)with name 'formname'.
document.forms.formName.elements['controlname']
gives you the control(s) (e.g. input, textarea, select) with name
'controlname' in the form with name 'formName'.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Closed Thread