<input type="text" id="txtName" />
<input type="checkbox" name="cbInput" value="1" onclick="fChange()" />
<input type="checkbox" name="cbInput" value="2" onclick="fChange()" />
<input type="checkbox" name="cbInput" value="3" onclick="fChange()" />
<script type="text/javascript">
function fChange(){
var objs = document.getElementsByName("cbInput");
var objValue="";
for(var i=0; i<objs.length; i++){
if(objs[i].type=="checkbox" ){
if(objs[i].checked){
objValue=objValue+","+objs[i].value;
}
}
}
if(objValue.length>0){
objValue=objValue.substr(1,objValue.length-1);
}
document.getElementById("txtName").value=objValue;
}
</script>
楼上不错哦