日期:2014-05-16  浏览次数:20324 次

复选框的传值

  比如     v1
    <input   type= "checkbox "     value= "v1 "   id= "sel "   name= "sel1 ">

  如果选择了   这个之后     就出现

<select>
<option   value= "1 "> +v1 </option>
<option   value= "2 "> -v1 </option>
</select>

    这个效果怎么实现啊!

------解决方案--------------------
<script>
function _createSelect(obj){
var sel = document.createElement( "select ");
var item = new Option( "+ " + obj.value, "1 ");
var item1 = new Option( "- " + obj.value, "2 ");
sel.options.add(item);
sel.options.add(item1);
document.body.appendChild(sel);
}
</script>
<input name= "sel " type= "checkbox " id= "v1 " value= "v1 " onclick= "_createSelect(this); "> <label for= "v1 "> v1 </label>
<input name= "sel " type= "checkbox " id= "v2 " value= "v2 " onclick= "_createSelect(this); "> <label for= "v2 "> v2 </label>
<input name= "sel " type= "checkbox " id= "v3 " value= "v3 " onclick= "_createSelect(this); "> <label for= "v3 "> v3 </label>
<input name= "sel " type= "checkbox " id= "v4 " value= "v4 " onclick= "_createSelect(this); "> <label for= "v4 "> v4 </label>
<input name= "sel " type= "checkbox " id= "v5 " value= "v5 " onclick= "_createSelect(this); "> <label for= "v5 "> v5 </label>
<input name= "sel " type= "checkbox " id= "v6 " value= "v6 " onclick= "_createSelect(this); "> <label for= "v6 "> v6 </label>