multiple buttons on a form

M

Matt

The ASP page has multiple buttons, and when the user clicks different
buttons, it will submit the form data to different URLs.

My first approach was to use BUTTON type, and triggers javascript function
to submit the form data. However, it didn't work properly and I changed to
use SUBMIT type.

<INPUT TYPE="BUTTON" NAME="action1" VALUE="Return to Main Search Page"
onClick="action1()">

function action1()
{ //etc...
document.myform.action = "main.asp"
document.myform.submit();
}

OR

<INPUT TYPE="SUBMIT" NAME="action1" VALUE="Return to Main Search Page"
onClick="action1()">

function action1()
{ //etc...
document.myform.action = "main.asp"
}

So which is the appropriate way? please advise. thanks!!
 
P

PW

Matt said:
The ASP page has multiple buttons, and when the user clicks different
buttons, it will submit the form data to different URLs.


When I need multiple buttons, I just have multiple forms as needed ...


<form ID="myform2" NAME="myform2" method="GET" action="tran_sale3.asp">
<button onclick="submit()" accesskey="P"
style="width:250px;height:50px;"><u>P</u>ROCEED</button>
</form>
<form ID="myform3" NAME="myform3" method="GET" action="tran_sale9.asp">
<button onclick="submit()" accesskey="C"
style="width:250px;height:50px;"><u>C</u>ANCEL</button>
</form>
 
C

CJM

Both the BUTTON and INPUT solutions will work, if you get your Javascript
right.

I tend to use <input type="submit"> because it has better browser support.

e.g. <input type="submit" name="submit1"
onclick="myform.action='main.asp';">

This is very similar to what you already have, so if there is still a
problem it will be with the Javascript syntax - in which case repost your
question to the .scripting.jscript NG.

hth

Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,158
Messages
2,570,882
Members
47,414
Latest member
djangoframe

Latest Threads

Top