
SUBMIT form with 3 different submit buttons - error
*sigh* I made the changes, but it still complains about wanting a ;....
Any ideas as to what I'm still doing wrong?
I can't believe I'm this thick...
thanks
================================================
<HTML>
<SCRIPT LANGUAGE="JavaScript">
function submitForm( whichaction ){
switch(whichaction)
{
CASE 1:
theForm.action="test1.html";
break;
CASE 2:
theForm.action="test2.html";
break;
CASE 3:
theForm.action="test3.html";
break;
Quote:
}
document.theForm.submit();
Quote:
}
</SCRIPT>
<BODY>
<form name="form" method="POST">
First Name: <input type="text" name="fname" size="20"><BR>
<INPUT TYPE="BUTTON" VALUE="test1" ONCLICK="submitForm(1);">
<INPUT TYPE="BUTTON" VALUE="test2" ONCLICK="submitForm(2);">
<INPUT TYPE="BUTTON" VALUE="test3" ONCLICK="submitForm(3);">
</form>
</BODY>
</HTML>
================================================
Quote:
> You are using VB syntax. Try this...
> <SCRIPT LANGUAGE="JavaScript">
> function submitForm( action ){
> switch(action)
> {
> case 1:
> theForm.action="test1.html";
> break;
> case 2:
> theForm.action="test2.html";
> break;
> case 3:
> theForm.action="test3.html";
> break;
> }
> document.theForm.submit();
> }
> </SCRIPT>
> Keep in mind that javascript is case sensitive.
> HTH
> Craig
> > I am trying to have a form with three possible "submit" buttons.
> > I need to go to 3 different pages, depending upon what the user selects.
> > I think I'm close, but can't quite get the syntax right.
> > Can someone help me? I get an error:
> > line 3
> > ; expected
> > Hmmm....
> > Thanks in advance!
> > ==============================================
> > <HTML>
> > <SCRIPT LANGUAGE="JavaScript">
> > function submitForm( action ){
> > SELECT CASE action
> > CASE "1"
> > theForm.action="test1.html"
> > CASE "2"
> > theForm.action="test2.html"
> > CASE "3"
> > theForm.action="test3.html"
> > }
> > </SCRIPT>
> > <BODY>
> > <form name="form" method="POST">
> > First Name: <input type="text" name="fname" size="20"><BR>
> > <INPUT TYPE="BUTTON" VALUE="test1" ONCLICK="submitForm(1);">
> > <INPUT TYPE="BUTTON" VALUE="test2" ONCLICK="submitForm(2);">
> > <INPUT TYPE="BUTTON" VALUE="test3" ONCLICK="submitForm(3);">
> > </form>
> > </BODY>
> > </HTML>