好心人给个思路看看~关于复选框的内容
每个复选框对应一个文本框,选中的文本框的值保存在A表,全部文本框的值都保存在B表,现在我可以保存了,但是无法修改了。。自己没办法把修改页面的选中的checkbox读出来~存的时候是用下面的办法存的,就是用targetObj的值对应文本框的值的。。
html>
<head> <title> CheckBox Selected By Ctrl </title> </head>
<script>
function datanameEnable(checkObj) {
var checkObjList = document.getElementsByName( "xuanxiang ");
if(checkObj.checked){
document.myForm.targetObj.value+=checkObj.value+ ", ";
}
if(!checkObj.checked){
document.myForm.targetObj.value= " ";
for(i=0;i <checkObjList.length;i++){
if(checkObjList[i].checked){
document.myForm.targetObj.value+=checkObjList[i].value+ ", ";
}
}
}
}
</script>
<body>
<form name=myForm action= " " method=post>
<input type= "checkBox " name= "xuanxiang " value= "a " onclick= "datanameEnable(this); "> 记录1 <br/>
<input type= "input " name= "a " value= " ">
<input type= "checkBox " name= "xuanxiang " value= "b " onclick= "datanameEnable(this); "> 记录2 <br/>
<input type= "input " name= "b " value= " ">
<input type= "checkBox " name= "xuanxiang " value= "c " onclick= "datanameEnable(this); "> 记录3 <br/>
<input type= "input " name= "c " value= " ">
<input type= "text " name= "targetObj " value= " " >
</form>
</body>
</html>
哪位大大帮忙给个办法告诉我怎么用targetObj的值来返还页面状态啊。。或者给段遇到这种情况你咋做的代码看看啊-。-
------解决方案--------------------不是很理解你的意思哦,加我QQ,中午或者晚上可以帮你看看,需要的话
------解决方案-------------------- <html>
<head> <title> CheckBox Selected By Ctrl </title> </head>
<script>
function datanameEnable(checkObj) {
var checkObjList = document.getElementsByName( "xuanxiang ");
if(checkObj.checked){
if(document.myForm.targetObj.value!= " ")
document.myForm.targetObj.value+= ", "+checkObj.value;
else
document.myForm.targetObj.value+=checkObj.value;
}
if(!checkObj.checked){
document.myForm.targetObj.value= " ";
var num=0;
for(i=0;i <checkObjList.length;i++){
if(checkObjList[i].checked){
if(num==0)
document.myForm.targetObj.value+=checkObjList[i].value;
else
document.myForm.targetObj.value+= ", "+checkObjList[i].value;
num++;
}
}
}
}
function a(){
var str=document.myForm.targetObj.value;
var strArray=str.split( ", ");
for(var i=0;i <strArray.length;i++){
var checkObjList = document.getElementsByName( "xuanxiang ");
for(var j=0;j <checkObjList.length;j++){
if(checkObjList[j].value==strArray[i]){
checkObjList[j].checked=true;
}
}
}
}
</script>
<body onload= "a() ">
<form name=myForm action= " " method=post>
<input type= "checkBox " name= "xuanxiang " value= "a " onclick= "datanameEnable(this); "> 记录1 <br/&g