Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

self-defined attributes : IE vs NS

Status
Not open for further replies.

wwEd

Programmer
Jul 8, 2003
2
US
I defined my own attribute in an INPUT tag of a form like this:

<INPUT TYPE=&quot;text&quot; NAME=&quot;field1&quot; MYTAG1=&quot;xyz&quot;>

then I access the form element in a javascript like this:

ThisElement = ThisForm.elements[0];

then I display my attributes value like this

alert(ThisElement.MYTAG1);

In IE the value is displayed in the alert as &quot;xyz&quot;
but in NS the value is displayed as &quot;undefined&quot;

Does NS not allow self-defined attributes like this?
Or do I not have the javascript coded properly for NS?

Thanks in advance.
 
As it's turning out maybe I should have posted this in the javascript forum?

Here's the actual code if anyone cares to try it. I don't want to use the actual field name so I can use my function to loop through any form. The js alert in IE displays the MYTAG values correctly, but in NS the MYTAG values are 'undefined'.

Also, IE will work with
Code:
if (ThisElement.MYTAG)
but NS fails the check so I need to use
Code:
if (ThisElement.MYTAG != &quot;&quot;)

Code:
<HTML><HEAD><TITLE></title>
<SCRIPT LANGUAGE=&quot;JavaScript1.2&quot; TYPE='text/javascript'>
function ParseForm (ThisForm) 
    {
    var ThisElement;

    for (var i = 0; i < ThisForm.elements.length; i++) 
        {
        ThisElement = ThisForm.elements[ i ];
        if (ThisElement.MYTAG != &quot;&quot;)
           {
	   alert('name=(' + ThisElement.name + '); mytag=(' + ThisElement.MYTAG + ')');
           }
        }
    return true;
    }
</script>
</head>
<BODY>
<FONT FACE=&quot;Arial, Tahoma, Verdana&quot; >
<FORM METHOD=POST NAME=&quot;MYFORM&quot; ACTION=&quot;&quot; onSubmit=&quot;return ParseForm(this);&quot;>
  <INPUT TYPE=&quot;text&quot; NAME=&quot;field1&quot; SIZE=&quot;15&quot; MAXLENGTH=&quot;25&quot; VALUE=&quot;&quot; MYTAG=&quot;abc&quot;>
  <INPUT TYPE=&quot;text&quot; NAME=&quot;field2&quot; SIZE=&quot;15&quot; MAXLENGTH=&quot;25&quot; VALUE=&quot;&quot; MYTAG=&quot;123&quot;>
  <INPUT TYPE=&quot;submit&quot; NAME=&quot;sub1&quot; VALUE=&quot;SUBMIT&quot; MYTAG=&quot;&quot;>
</form>
</body></html>

Any and all help is greatly appreciated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top