[thelist] javascript - how to refer to (x)html elements

Tim Burgan burgan at iprimus.com.au
Wed Nov 12 20:44:20 CST 2003


Hi Jeff.

Your suggestion:

 : <form action="" method="get"
 :       onsubmit="collectInfo(this.form)">
 :
 : function collectInfo(oForm)
 : {
 :   var elementName = 'myName';
 :   var oElement = oForm.elements[elementName];
 :   alert('The value is ' + oElement.value);
 : }

I can't seem to get working for some reason.
It's as if the oForm isn't being "read" properly or something like that.

I've uploaded a page [1], where you can see the two variations.
'Task 1' on the page is the method you've just suggested, and 'Task 2' is the
currently working method using the forms array.

If you have the time can you please take a look to see what's going on.

[1] <http://www.greaterthani.com/05_programming/week5b.htm>

Thanks for the help
Tim




More information about the thelist mailing list