?
Solved

1 Form using 2 Submit Buttons

Posted on 2004-11-23
8
Medium Priority
?
151 Views
Last Modified: 2010-04-25
I have a form and need to have 2 submit buttons on it and depending upon which button (both for updates) is pressed the database will update accordingly.
Dreamweaver won't allow this, and I don't know where to start.

Can someone point me in the right direction?
0
Comment
Question by:Benno2805
8 Comments
 
LVL 19

Expert Comment

by:webwoman
ID: 12655020
You can't have two submit buttons.

What EXACTLY are you trying to do?
0
 
LVL 1

Author Comment

by:Benno2805
ID: 12655101
It's information entered by the client and it can be modified or made inactive. Depending on which button is pressed, one will do the modifications, the other will make the record inactive both via Updates.
0
 
LVL 1

Author Comment

by:Benno2805
ID: 12655502
OK, I've thought that it may be easier doing it with radio buttons and if RadioButton1 is active then 'do this update' if radionbutton2 is active then do this update...

But I don't know how to put it in the code, especially since Dreamweaver puts in a lot of stuff you don't really need.

0
Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

 
LVL 54

Assisted Solution

by:Ryan Chong
Ryan Chong earned 75 total points
ID: 12656779
You need to have a form onsubmit event, where it will set to call a javascript function to check which radio button you have selected, and then determine what action (we can change the form's Action just before the posting) to take, clear?

Post your code here if necessary, so that we can help you amend it.

regards
0
 
LVL 2

Assisted Solution

by:painted
painted earned 75 total points
ID: 12657214
You could create 2 update 'command' pages, one for each button.  Each button would simply need to be a link to the correct command page.  Pass the parameters to each command page for the update via Request.Form. Have the command pages redirect back to the form page (or where ever you need the user to go).  You will need to add the Response.Redirect line to each command page manually.  To the user, this works virtually seamlessly.  

HTH,
painted
0
 
LVL 10

Accepted Solution

by:
Havin_it earned 225 total points
ID: 12660914
There only needs to be one 'receiving' page - you can just have a value added to the form according to which button you press, to tell the receiving page what to do with the data. How about this:

<html>
<head>
<script>
function doModify() {
document.forms.myForm.mod.value=1;
document.forms.myForm.submit();
}
</script>
</head>
<body>
<form name="myForm" action="update.php" method="post">
<input type="hidden" name="mod" id="mod" value="0"></input>
...
<input type="submit" name="inactive" value="Make data inactive"></input>
<input type="button" name="update" value="Update data" onclick="doModify();"></input>
</form>
</body>
</html>

Then your receiving page (it could even loop back to this page if you wish) can be coded to do the update if the form variable mod=1, and deactivate it if mod=0.
0
 
LVL 1

Author Comment

by:Benno2805
ID: 12667735
Thanks guys, I took a little bit of advice from each of you and i've come up with a clean, reliable solution.

Thanks again.
0
 
LVL 2

Expert Comment

by:painted
ID: 12668975
That's great Benno2805.  Glad things worked out for you.

painted
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those who don't know, Adobe Dreamweaver is a popular commercial web editor that enables you to design, build and manage complex websites. The editor is a WYSIWYG (What You See Is What You Get) web editor, which means that you can create your web…
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question