said_fox
08-15-2003, 03:54 PM
A page have two forms. On certain event I want to transfer the value of one form's elements to
the other's elements.
Consider the following code:
<form name="form1">
<input type="text" name="txt1" onblur="trans(this)">
<input type="text" name="txt1" onblur="trans(this)">
</form>
<form name="form2">
<input type="text" name="txt1">
<input type="text" name="txt2">
</form>
I had written the following code for the trans() function:
function trans(arg){
val = arg.value;
nam = arg.name;
document.form2.nam.value = val;
}
You may noticed that the elements names are identical. The nam Variable holds the corresponding
element's name of form1.
An error message is obtained from the above code it tolds that "document.form2.nam is null or not an object"!
So How can I use the nam variable to supply dynamically the form2's element name?
as coded in "document.form2.nam.value = val;"
Is there any help?
the other's elements.
Consider the following code:
<form name="form1">
<input type="text" name="txt1" onblur="trans(this)">
<input type="text" name="txt1" onblur="trans(this)">
</form>
<form name="form2">
<input type="text" name="txt1">
<input type="text" name="txt2">
</form>
I had written the following code for the trans() function:
function trans(arg){
val = arg.value;
nam = arg.name;
document.form2.nam.value = val;
}
You may noticed that the elements names are identical. The nam Variable holds the corresponding
element's name of form1.
An error message is obtained from the above code it tolds that "document.form2.nam is null or not an object"!
So How can I use the nam variable to supply dynamically the form2's element name?
as coded in "document.form2.nam.value = val;"
Is there any help?