1)DOM method to get ID (IE is bad since lets you get name this way, will not work like tht for other browsers) 2)use the form object element array 3)use the form object element array, just referenced another way 4)IE only way (so do not use)
You can also do
document.forms[0]... or document.forms["formName"]
instead of
document.formName
Eric
Roy Ivar Moe
Greenhorn
Joined: Jun 22, 2006
Posts: 21
posted
0
Hey,
Here is an example form:
(1). - This is used to get the value of an element by using its id to reference the element. I.e. in this example 1 will be returned. As long as your element has an id, I would recommend this way.
(2). - The browser maintains a list of all control elements within a form. You can use this list to get the value of an element. I.e. in this example 1 will be returned. You can also use the list index to fetch an element value e.g. I.e. in this example 1 will be returned. However, the elements list should not be used to fetch elements values, it should instead be used when you need to iterate all the elements of a form e.g. to disable all elements.
(3). - This is used to get the value of an element by using its id or name to reference the element. I.e. in this example 2 will be returned. I still recommend (1).
(4). - This is used to get the value of an element by using its id or name to reference the element. I.e. in this example 2 will be returned. This method is proprietary to JScript, so I suggest you forget about (4) and use (1) instead.
Hope this helps,
RIM
Nakata kokuyo
Ranch Hand
Joined: Apr 13, 2005
Posts: 437
posted
0
thanks for warm reply, jst wondering , as first is not recommended to use, i found most of the ajax application, using getElementById(), am i right ?