Click to See Complete Forum and Search --> : Passing a field name incorrectly.


ade
04-04-2003, 03:40 PM
Field name PSM_CSC is auto-generated by 3rd party application in a form. Want to rename PSM_CSC to CSC in a form by using the routine below and pass it to an another application. The code below works with an IE browser (even without the documet.forms statement), but does not work when opened with a Netscape browser. I want a routine that works with any browser. (I know nothing about Javascript)


<input TYPE="text" NAME="PSM_CSC" SIZE="3" VALUE="">


<script LANGUAGE="JavaScript1.2">
<!--
document.all.PSM_CSC.name = "CSC";
document.all.PSM_CSC.id = "CSC";
document.forms[0].PSM_CSC.name = "CSC";
-->

khalidali63
04-04-2003, 03:59 PM
I know that the correct way of doing this will be something like this

var frm = document.getElementById("form1");
frm.setAttribute("name","newForm");

the code above follows W3C DOM standard.

The above will work in NS6+ for sure

Cheers

Khalid

ade
04-04-2003, 04:03 PM
Thanks, I'll give it a try!

ronmcdonald
04-04-2003, 04:44 PM
Added this...

var frm = document.getElementById("PSM_CSC");
frm.setAttribute("name","CSC");

still not working. Still researching.

Ron,

khalidali63
04-04-2003, 05:17 PM
Originally posted by ade
The code below works with an IE browser (even without the documet.forms statement),.........
-->

The code I posted earlier now that I tested, it works fine with NS.You already have IE solution.

For the ns part of the code to work the form must have an id attribute set or considering that you have one form in the page you can do this

var frm = document.getElementsByTagName("form")[0];


Cheers

Khalid