单击复选框后如何将数据加载到文本字段中,并且在这样做之后,我需要禁用该文本框,但是再次取消选中它时,需要删除该数据并使文本框启用以手动输入数据。我试过这段代码,我是 jquery/ajax 的新手,不知道如何解决这个问题。
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$('#chk').click(function(){
if($(this).is(":checked"))
$("#txtaddress").removeAttr("disabled");
else
$("#txtaddress").attr("disabled" , "disabled");
// here, i don't know how do i assign $row['address'] to txtaddress by
// using php mysql
});
});
</script>
<!-this is my html code-->
<form>
<input type="checkbox" id="chk" name="chk">Same as home address?
<input id="txtaddress" name="txtaddress" disabled type="text">
</form>