<input type='text' name='jiage' value='' size='10' onclick='tocheckbox()'> <input type='checkbox' name='id_checkbox' id='ch'>
<script language="javascript"> function tocheckbox()
{
var a=document.getElementById("ch");
alert(a)
a.checked =true;
} </script>
<script language="javascript"> function tocheckbox()
{
var a=document.getElementById("ch");
alert(a)
a.checked =true;
} </script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title> new document </title>
</head><script type="text/javascript">
String.prototype.trim = function() {
return this.replace(/^\s+/, '').replace(/\s+$/, '');
}window.$ = function(id) {
if(typeof id == 'string') {
return document.getElementById(id);
}
return id;
}function checkboxChange(txt, ck) {
$(ck).checked = $(txt).value.length > 0;
}
</script><body>
<input type="text" name="jiage" id="jiage" size="10" onpropertychange="checkboxChange(this, 'ch')" oninput="checkboxChange(this, 'ch')">
<input type="checkbox" name="id_checkbox" id="ch">
</body></html>
<script language="javascript">
function aa(e)
{var value=e.value.replace(/(^\s+)|(\s+$)/g,"")
if(value!="")
{e.nextSibling.checked =true} //得保证text checkbox 之间没其他元素
else
{e.nextSibling.checked =false}}
</script>
个人觉得 用onblur来比较好 至少执行的次数onpropertychange少