PDA

Click to See Complete Forum and Search --> : Can you switch on Submit buttons?


joey o.
Oct 9th, 2000, 07:17 PM
Hi,
I'm really liking this stuff now, but lots of questions. How can I do a select case or If statement to determine what action goes in the form tag? I want to use more than one submit button on my calling html page to determine which ASP page to call. I want to use "real" buttons, not one's I have to make by pics or tables.
Thanks

Oct 10th, 2000, 08:21 AM
Hi, why not try anything like this:

--------------------------------------------------
<script language="javascript">
<!--
function whereto( )
{
if (condition)
{
window.parent.location.href = "destination1.asp";
}
else
{
window.parent.location.href = "destination2.asp";
}
}
//-->
</script>

<form action="whatever.asp" onsubmit="whereto()">
---------------------------------------------------

Good luck!

Mark Sreeves
Oct 10th, 2000, 09:51 AM
try this:


whatever.html


<html>

<head>
<script language=javascript>
function doit(x)
{

switch(x)
{
case 1:
document.frm1.action="some.asp";
break;
case 2:

document.frm1.action="someother.asp";
break;
}

document.frm1.submit();
}
</script>
</head>

<body>

<form name=frm1>
<input name=txt1>
<input name=txt2>
</form>
<form name=frm2>
<input type='button' name=but1 onClick="doit(1)" value="Submit to choice 1">
<input type='button' name=but2 onClick="doit(2)"value="Submit to choice 2">
</form>

</body>

</html>



someother.asp



<%@ Language=VBScript %>
<HTML>
<HEAD>

</HEAD>
<BODY>

<h1>someother asp</h1>
<%


response.write("Text 1: " & request("txt1") & "<BR>")
response.write("Text 2: " & request("txt2") & "<BR>")



%>


</BODY>
</HTML>




some.asp


<%@ Language=VBScript %>
<HTML>
<HEAD>

</HEAD>
<BODY>

<h1>some asp</h1>
<%
response.write("Text 1: " & request("txt1") & "<BR>")
response.write("Text 2: " & request("txt2") & "<BR>")
%>

</BODY>
</HTML>

joey o.
Oct 10th, 2000, 11:12 AM
Thanks!
I'm liking this even more now! YEE-HAA!