开发者

Duplicating value from one form to another

开发者 https://www.devze.com 2023-01-31 21:42 出处:网络
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 stil

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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消