如何將輸入框(form name="form1"
)中的值回顯到輸入框(form name="form2"
)如何將輸入框(<form name =「form1」>)中的值回顯到輸入框(<form name =「form2」>)
我想出瞭如何在第一個窗體中回顯輸入內容以及如何使用div ..但我無法弄清楚如何從第一個窗體(form1
)的輸入框中傳入inpus ..以第二種形式輸入到輸入框中(form2
)。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript">
function FillBilling(f) {
f.billingname.value = f.shippingname.value;
f.billingcity.value = f.shippingcity.value;
}
function changeRadius1(){
var name_input = document.getElementById('name_input').value;
document.getElementById('radius1').innerHTML = name_input;
}
function changeRadius2(){
var city_input = document.getElementById('city_input').value;
document.getElementById('radius2').innerHTML = city_input;
}
</script>
</head>
<body>
<b>Mailing Address FORM1</b><br><br>
<form name="form1">
Name:<input type="text" name="shippingname" onkeyup="FillBilling(form1); changeRadius1()">
<br>City:<input type="text" name="shippingcity" onkeyup="FillBilling(form1); changeRadius2()">
<br><br>
Name:<input type="text" id="name_input" class="name_input" name="billingname" onkeyup="FillBilling(form2)"><br>
City:<input type="text" id="city_input" class="city_input" name="billingcity" onkeyup="FillBilling(form2)">
</form>
<br>
<P>
<b>Billing Address FORM2</b><br><br>
<form name="form2">
Name:<input type="text" id="name_input" class="name_input" name="billingname"><br>
City:<input type="text" id="city_input" class="city_input" name="billingcity">
</form>
<br><b>Billing Address TEXT</b><br><br>
<div class="yourcode">Name: <span id="radius1"></span></div>
<div class="yourcode">City: <span id="radius2"></span></div>
</body>
</html>
我希望這不是一個愚蠢的問題..答案應該是明顯的..但我在JS的開頭..所以感謝您的幫助。
備註:一個'id'在你的所有HTML文檔中必須是唯一的,這意味着你應該重新命名你的輸入'id's。 – sp00m