as***************@gmail.com wrote:
Actually , I wrote one javascript to retrieve the name of the form in
one particular page.
<form name="myform" >
Click Here to check the value of name button
<input type=button name='name' value='Click Here'
onclick='checkbutton();' >
</form>
As it was already suggested, there are two forbidden names for form
elements you *never ever* use unless with a gun against your temple:
"name" and "submit". Each of them means huge scripting troubles in the
immediate future.
But presuming that you have to deal with a 3rd party form and there is
absolutely no way to insist on server-side changes...
Normally when you are using DOM 0 methods the engine understands that
you are willing to reach form elements and when you are using
getAttribute then the engine understands that you want to reach element
attributes. That works for all browsers except IE which presumes by
default that all users are idiots and what they asking for is not what
they really want (thus on getAttribute it still returns element from
form collection). This way the task is to bypass somehow this "parasite
neuristic". They way we are suggesting to our clients is:
....
// Please note that DOM 0 uses squared brakets
// notation, not parenthesis like in your original code.
// Otherwise it will break out on any normal browser:
var f = document.forms["myform"];
alert(f); // form object
alert(f.attributes.getNamedItem('name').nodeValue) // form name;
alert(f.elements['name'].value) ;