a.htm
<html>
<head>
<title>选择值页面</title>
<script language=javascript>
//获取选择的值
function getSelTest()
{
var selTxt="";
for(var i=0;i<document.form1.test.length;i++)
{
if(document.form1.test[i].checked)
selTxt+=document.form1.test[i].value+"|";
}
return selTxt;
}
function dd()
{
if(getSelTest()=="")
{
alert('请先选择至少一项');
return false;
}
document.form1.chkStr.value=getSelTest();
return true;
}
</script>
</head>
<body>
<form action="b.asp" name="form1" method="post" onsubmit="return dd()">
<input type="checkbox" name="test" value="計算機">計算機</input>
<input type="checkbox" name="test" value="英語">英語</input>
<input type="checkbox" name="test" value="外貿">外貿</input>
<input type="checkbox" name="test" value="軟件工程">軟件工程</input>
<input type="checkbox" name="test" value="市場營銷">市場營銷</input>
<input type="hidden" name="chkStr" >
<input type="submit" value="hit" />
</form>
</body>
</html>
b.asp
<html>
<head>
<title>显示选择的值</title>
<script language=javascript>
<%
Dim chkStr,chkAry,IsChoice,i
chkStr=Request.Form("chkStr")
IsChoice=True
With Response
IF chkStr=="" Then
IsChoice=False
.Write "alert('还没有选择值返回前一页选择至少一项');"
.Write "self.location='a.asp';"
End IF
End With
%>
</script>
</head>
<body>
<%
With Response
IF IsChoice Then
chkStr=Mid(chkStr,1,Len(chkStr)-1)
chkAry=Split(chkStr,"|")
.Write "选择的值为"
For i=0 To Ubound(chkAry)
.Write chkAry(i)&"<br>"
Next
End IF
End With
%>
</body>
</html>
两个文件存在同一目录测试