1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
   |  
<!DOCTYPE html>
<head>
<title> Untitled </title>
<script type="text/javascript">
function test(checkObj){
 
		var oURL   = document.getElementById('retURL');
		var oNames = document.getElementById('docNames');	
 
        var checkGroup = checkObj.form[checkObj.name];
        var checkGroupLen = checkGroup.length;
        var valueList = new Array();
		var titleList = new Array();
        for (var i=0; i<checkGroupLen; i++){
           if(checkGroup[i].checked){
              valueList[valueList.length] = checkGroup[i].value;
			  titleList[titleList.length] = checkGroup[i].title;
           }
        }
        oURL.value = 'http://www.site.com/page.php?var='+valueList.join(',');
		oNames.value = titleList.join(',');
        return;
     }
 
</script>
</head>
<body>
<form name="myform">
  Doc A <input type='checkbox' name="ckb[]" value='1' title="doc_a" onclick="test(this)">
  Doc B <input type='checkbox' name="ckb[]" value='2' title="doc_b" onclick="test(this)">
  Doc C <input type='checkbox' name="ckb[]" value='3' title="doc_c" onclick="test(this)">
  <br><input type='text' name='retURL' style="width:300px" id='retURL'>
  <br><input type='text' name='docNames' style="width:300px" id='docNames'>
  </form>
</body>
</html> | 
Partager