我想通过点击复选框显示联系地址和永久地址。 对于例如:如果我输入联系地址并单击复选框,则应在永久地址字段中显示相同的地址。如何使用jquery做到这一点? 提前谢谢..
答案 0 :(得分:2)
我是通过java脚本完成的。可能这对所有人都有帮助。
复选框代码:
<input type="checkbox" name="present" onclick="permanent(this.form)">
Java脚本代码:
<script language="JavaScript">
function permanent(p) {
if(p.present.checked == true) {
p.per_add.value = p.temp_address.value;
p.per_city.value = p.temp_city.value;
p.per_state.value = p.temp_state.value;
p.per_country.value = p.temp_country.value;
p.per_pin.value = p.temp_pin.value;
}
}
</script>
答案 1 :(得分:0)
联系地址
<input type="text" id="contact">
<input type="checkbox" id="check">
Contact Address <input type="text" id="permanent">
jquery是
$('#check').click(function() {
var c=$('#contact').val();
$("#permanent").val(c);
});
答案 2 :(得分:0)
<script language="JavaScript">
$(document).ready(function(e) {
$('#check').click(function() {
var c=$('#contact').val();
$("#permanent").val(c);
});
});
</script>
</head>
<body>
<form>
<input type="text" id="contact">
<input type="checkbox" id="check">
Contact Address <input type="text" id="permanent">
</form>
答案 3 :(得分:0)
function filladd()
{
if(filltoo.checked == true)
{
var tal11 =document.getElementById("tal").value;
var dist11 =document.getElementById("dist").value;
var pin11 =document.getElementById("pin").value;
var copytal =tal11 ;
var copydist =dist11 ;
var copypin =pin11 ;
document.getElementById("tal1").value = copytal;
document.getElementById("dist1").value = copydist;
document.getElementById("pin1").value = copypin;
}
else if(filltoo.checked == false)
{
document.getElementById("tal1").value='';
document.getElementById("dist1").value='';
document.getElementById("pin1").value='';
}
}
<label>Tal</label>
<br/>
<input type="Text" id="tal" name="Taluka1" class="" placeholder="" >
<br/>
<label>Distic</label>
<br/>
<input type="Text" id="dist" name="Distric1" placeholder="">
<br/>
<label>Pincodes</label>
<br/>
<input type="Text" id="pin" name="pincode1" placeholder="">
<br/>
<input type="checkbox" value="" name="filltoo" id="filltoo" onclick="filladd()" />Permanent Address same as Current Address <br/>
<label>Tal</label>
<br/>
<input type="Text" id="tal1" name="Taluka1" placeholder="" >
<br/>
<label>Distic</label>
<br/>
<input type="Text" id="dist1" name="Distric1" placeholder="">
<br/>
<label>Pincodes</label>
<br/>
<input type="Text" id="pin1" name="pincode1" placeholder="">
<br/>