zhao790
asked on
How to get check box value the user selected at same asp page?
I am writing one asp page. In this page there is one check box and when clinking the Submit button, depending on the check box value, will go to two different links. My question is how do i get check box value at same page to go to one of link?
You would use javascript to pull this one off. Something like this:
<form name=myForm method=post target="Page1.asp">
<input type=checkbox name=chkChangeTarget onClick="ChangeTarget();">
...
</form>
<script language=javascript>
function ChangeTarget()
{
if(myForm.chkChangeTarget. checked)
myForm.Target = "Page2.asp";
else
myForm.Target = "Page1.asp";
return;
}
</script>
<form name=myForm method=post target="Page1.asp">
<input type=checkbox name=chkChangeTarget onClick="ChangeTarget();">
...
</form>
<script language=javascript>
function ChangeTarget()
{
if(myForm.chkChangeTarget.
myForm.Target = "Page2.asp";
else
myForm.Target = "Page1.asp";
return;
}
</script>
ASKER
Thank for your response.
My asp code written by VB script. Can the VB script get same information or implement same functionality?
My asp code written by VB script. Can the VB script get same information or implement same functionality?
zhao,
This is client-side code that will run on the user's computer. It is not actually ASP. If you like I could post the same code using server-side VBScript but note that this will do exactly the same thing, only it won't work in non-microsoft browsers.
This is client-side code that will run on the user's computer. It is not actually ASP. If you like I could post the same code using server-side VBScript but note that this will do exactly the same thing, only it won't work in non-microsoft browsers.
(sorry, i meant "client side vbscript" not "server-side vbscript" in the above post.)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<script language=javascript>
function ChangeTarget()
{
if(myForm.mycheck.checked)
myForm.action= "Page2.asp";
else
myForm.actiont = "Page1.asp";
myForm.submit()
}
</script>
function ChangeTarget()
{
if(myForm.mycheck.checked)
myForm.action= "Page2.asp";
else
myForm.actiont = "Page1.asp";
myForm.submit()
}
</script>
document.getElementsbyName
<script>
function chk1_onClick(obj)
{
if(this.checked)
{
location.href='page1.asp';
}
else
{
location.href = 'page2.asp';
}
}
end function
</script>
<input type=checkbox name='chk1' onclick='chk1_onClick(this