Click to See Complete Forum and Search --> : differentiating between image based submit buttons


poab
03-07-2003, 12:16 PM
Hi,

This could have gone in the html section but I think it's more appropriate here as it involves asp and the form method I'm using may not be the best.

The file I'm refering to is here (http://www.232nd.net/home_drop/home_twentyfour.asp).

I've got an asp page that has a form with four submit button. Once one of them is pressed the page is reloaded and it tests which, if any of the submit buttons was pressed. This is done by giving each submit button it's own name and the value "open". Once that's done the asp writes the content to the page and it's downloaded by the browser.

The problem is the submit buttons are big and ugly and don't fit the design, so I wanted to use images as the submit buttons. Unfortunatly whilst I can give these name attributes, I can't give them values, and therefore I don't know what to test against.

Is there a quick solution or do I need to find another way of doing it? Can anyone help?

cheers.

Ribeyed
03-07-2003, 03:09 PM
hi,
here is some code for your problem. I am sure you can change it where you need to:



<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<%
val = request.form("val")
if val = "yes" then

username = request.form("username")
for each item in request.form
if item = "submit1.x" then
response.write "button 1 was pressed"
elseif item = "submit2.x" then
response.write "button 2 was pressed"
elseif item = "submit3.x" then
response.write "button 3 was pressed"
end if
next
end if
%>
<form action="/imagesubmit.asp" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td><input name="username" type="text"></td>
<td><input type="image" name="submit1" src="image1.gif"></td>
<td><input type="image" name="submit2" src="image2.gif"></td>
<td><input type="image" name="submit3" src="image3.gif"></td>
</tr>
</table>
<input name="val" type="hidden" id="val" value="yes">
</form>
<%=username%>
</body>
</html>

poab
03-07-2003, 04:17 PM
Hi,

thanks very much :)

Ribeyed
03-07-2003, 08:57 PM
your welcome;)

poab
03-10-2003, 12:34 PM
Hmmm, for some reason that didn't work:(

However, I did steal your <input type="hidden"> bit, and if I stick each button in it's own form and then test which hidden field got submitted then it does work - :D

thanks again