Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting Form Button Pressed In ASP

Status
Not open for further replies.

Skittle

ISP
Sep 10, 2002
1,528
US
Hi,

I have a form that accepts parameters of week and year and then actions another page that displays data for the parameters. At the moment the form has a submit and clear button. I would also like to add another submit button that does exactly the same thing as the standard submit button but will have a name and value of 'Excel'.

I then want the page actioned be my form to detect if the user clicked on the 'Excel' button so that I can display the data results in an Excel formated table instead of an html formatted table.

How can I detect if the user submitted the form by hitting the 'Excel' button instead of the other standard 'Submit' button?
 
Try this code

Code:
<html>
<body>
<%
for each item in Request.Form 
	Response.Write &quot;<b>&quot; & item & &quot;</b>: &quot; & request(item) & &quot;<BR>&quot;
next
%>
<HR>
<form action=TestGabe.asp method=post>
<input type=submit value=HTML name=ShowType id=ShowType><BR>
<input type=submit value=Excel name=ShowType id=ShowType>
</form>
</body>
</html>

You give each submit button a unique value. Then in your asp page you check you check the request object for the different submit button's values. The button that was clicked with have a value passed to your page.

Hope this helps,

Gabe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top