By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 2,177 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

2 Submit Buttons Of Type Image: Which was used?

P: n/a
I have two buttons on my form and need to know which was
clicked. If I setup the buttons like this:

<input type="submit" value="submit" name="submit_to_array">
<input type="submit" value="submit" name="submit_to_db">

I can look in the Request.Form collection to see if
submit_to_array or submit_to_db appears to determine which
button was clicked. This works fine.

The problem is, I want to use an image instead of the
default button and I have changed the type from submit to
image, ie:

<input type="image" value="submit" name="submit_to_array"
src="images\add.gif">
<input type="submit" value="submit" name="submit_to_db"
src="images\submit.gif">

But when I do this I dont get either submit_to_array or
submit_to_db appearing in the Request.Form collection.
Where has this gone?

TIA,

Colin
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Colin Steadman" wrote in message
news:ea****************************@phx.gbl...
: I have two buttons on my form and need to know which was
: clicked. If I setup the buttons like this:
:
: <input type="submit" value="submit" name="submit_to_array">
: <input type="submit" value="submit" name="submit_to_db">
:
: I can look in the Request.Form collection to see if
: submit_to_array or submit_to_db appears to determine which
: button was clicked. This works fine.
:
: The problem is, I want to use an image instead of the
: default button and I have changed the type from submit to
: image, ie:
:
: <input type="image" value="submit" name="submit_to_array"
: src="images\add.gif">
: <input type="submit" value="submit" name="submit_to_db"
: src="images\submit.gif">
:
: But when I do this I dont get either submit_to_array or
: submit_to_db appearing in the Request.Form collection.
: Where has this gone?

Hi Colin...

There is more than one way to accomplish this. This is one way...

Create a hidden element. If you want to use an image to submit, then add an
onclick event to an image. It doesn't have to be an input element. The
onclick event calls a script that sets the value you want to the hidden
element and then submits the form.

http://kiddanger.com/lab/form.html

Click either image to trigger the event.
Here is the code for the asp document.

<%@ Language=VBScript %>
<%
Option Explicit
Response.Buffer = True
dim submitTo
submitTo = Request.Form("submitTo")
Response.Write("You clicked: " & submitTo & vbCrLf)
%>

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
Jul 19 '05 #2

P: n/a
Dan
All you need to do is check the x or y coordinate.

Simply:

If Request.Form("Image1Name.x") <> "" Then
...
ElseIf Request.Form("Image2Name.x") <> "" Then
...
End If

"Colin Steadman" <ms**@N0Tpart0FemailADdRESSScolinsteadman.com> wrote in
message news:ea****************************@phx.gbl...
I have two buttons on my form and need to know which was
clicked. If I setup the buttons like this:

<input type="submit" value="submit" name="submit_to_array">
<input type="submit" value="submit" name="submit_to_db">

I can look in the Request.Form collection to see if
submit_to_array or submit_to_db appears to determine which
button was clicked. This works fine.

The problem is, I want to use an image instead of the
default button and I have changed the type from submit to
image, ie:

<input type="image" value="submit" name="submit_to_array"
src="images\add.gif">
<input type="submit" value="submit" name="submit_to_db"
src="images\submit.gif">

But when I do this I dont get either submit_to_array or
submit_to_db appearing in the Request.Form collection.
Where has this gone?

TIA,

Colin

---

Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.687 / Virus Database: 448 - Release Date: 5/16/2004
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.