轉自百度知道
"
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>無標題文檔</title></head><body>a <input type=checkbox value="t" name="t" >b<input type=checkbox value="x" name="x" />c<input type=checkbox value="x" name="x" />d<input type=checkbox value="x" name="x" /><input type="button" value="確定" name="b" onClick="onClick()"><INPUT type=reset value=重做 name="Reset"><br><input name="yourResult" type="text" id="yourResult" size="50"><script language="JavaScript" type="text/javascript">function onClick(){ var ChkboxValue = ""; var chks = document.getElementsByTagName("INPUT"); for(var i=0; i<chks.length; i++) { if(chks[i].type=="checkbox" && chks[i].checked ) { if ( ChkboxValue == "" ) ChkboxValue = chks[i].value; else ChkboxValue += ","+chks[i].value; } } if (ChkboxValue == "") ChkboxValue = "你沒有選擇!"; else ChkboxValue = "你選擇的結果是:"+ChkboxValue; document.getElementById("yourResult").value = ChkboxValue;}</script></body></html>
"