Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 19th, 2004, 09:49 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
Default multiple submit buttons

Hi,



I have this form that has 2 buttons, which are both pointing at the same page, but waht it to display different stuff. Now 1 of the submit buttons (button2) is just manipulating data on the form. The other other is the one that actually doing the submit to the db, but want it to say that it was successfull, and display what was submitted. I'm using a hidden input to indicate when the acutal submit btn is pressed, now what I don't understand, is that it takes 2 clicks on the submit to actually set the value of the hidden value, can anyone tell me why??? Or is there a better way of doing this???



<html>
<head>
</head>

<body>
<form name="Add" action="insert.asp" method="get">

<%
 if request.QueryString("flag") <> "" then
%>
 <center>
  <h2>successful text</h2>
 </center>
<%
 else
%>
<input type='submit' value='Submit' name='bsubmit'>
<input type="submit" value="button2" name="bsubmit">

<%
 if request.QueryString("bsubmit") = "button2" then
  Response.Write("Other button was pressed")
 elseif Request.QueryString("bsubmit") = "Submit" then
%>
<input type='hidden' name='flag' value='active'>
<%
 end if

 end if
%>

</form>
</body>
</html>



 
Old March 19th, 2004, 11:18 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If the second button doesn't actually do a submit, then make it:
<input type="button"> not <input type="submit">

To set the hidden input field *client side* (i.e. avoiding a round trip to the server), you need to use javascript which runs in the client browser. At the moment you are hitting the submit button, sending the form to the server, which then writes out a value for the hidden input field, then you are submitting the form again (hence, two submits).

Cheers
Ken

Microsoft MVP - Windows Server (IIS)
www.adOpenStatic.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
2 Submit Buttons ... HOW? Benno Dreamweaver (all versions) 1 November 23rd, 2004 12:14 PM
multiple Image submit buttons set default to last sam HTML Code Clinic 2 June 30th, 2004 02:33 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.