SUBMIT form with 3 different submit buttons - error 
Author Message
 SUBMIT form with 3 different submit buttons - error

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"

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>



Thu, 11 Mar 2004 22:01:05 GMT  
 SUBMIT form with 3 different submit buttons - error
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;

Quote:
}

document.theForm.submit();
Quote:
}

</SCRIPT>

Keep in mind that javascript is case sensitive.

HTH

Craig


Quote:
> 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>



Fri, 12 Mar 2004 00:56:03 GMT  
 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>



Fri, 12 Mar 2004 06:47:17 GMT  
 SUBMIT form with 3 different submit buttons - error
CASE should be case ...

JScript is case sensitive.

--

Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:
> *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;
> }
> document.theForm.submit();
> }
> </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>

> ================================================


> > 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>



Fri, 12 Mar 2004 07:59:30 GMT  
 SUBMIT form with 3 different submit buttons - error

Quote:
> I can't believe I'm this thick...

Compared with VB, java/javascript are a bit more strict about syntax. For a
beginner that can be a pain. For an expert it is a good thing. You'll get
used to it.

Craig



Fri, 12 Mar 2004 08:54:26 GMT  
 SUBMIT form with 3 different submit buttons - error
That did it - thanks for spelling it out for me.

Funny, all those programming classes I took in the good ole days of DOS said
to
write all reserved words in CAPS.



Quote:
> CASE should be case ...

> JScript is case sensitive.

> --

> Michael Harris
> Microsoft.MVP.Scripting



Fri, 12 Mar 2004 14:57:53 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Help with Cast in Interbase !!

2. Link to Win95???

3. SUBMIT form with 3 different submit buttons - error

4. form submit using different submit buttons

5. How to revert to BDE4.51 from BDE5

6. DGBrid, Query

7. Inline

8. use ram with tp

9. Sound Blaster

10. Memo field in DBGrid

11. form submits hrefs images and submit buttons

12. Submitting Form WITHOUT Submit Button

 

 
Powered by phpBB® Forum Software