Duplicating value from one form to another
Say, I have got a form which uses the same values as my other form but the first form contains data which I would like to have on my second form. Such as something from a drop-down list box. I am still a noob at HT开发者_StackOverflow中文版ML and dont know how to do this. Any assistance is gratefully appreciated!
With javascript:
<form>
<input type="text" name="textBox" id="textBox" onchange="document.getElementById('textBox2').value = document.getElementById('textBox').value;">
</form>
<form>
<input type="text" name="textBox2" id="textBox2">
</form>
You can do this for any field.
You could do something like this:
var form1,
i = 1;
while (form1 = document.getElementById("form1_input" + i)) {
document.getElementById("form2_input" + i).value = form1.value;
i += 1;
}
精彩评论