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 August 4th, 2005, 08:43 PM
Authorized User
 
Join Date: Jun 2005
Posts: 42
Thanks: 0
Thanked 1 Time in 1 Post
Default Submit forms

Hi there, can anyone reply with a sample code of how can I have several submit buttons on the same form? a sample of two or three button will do!

arnniema
__________________
arnniema
 
Old August 5th, 2005, 01:00 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

This is just as easy as having one button:

<input type="submit" value="button 1" name="button1" id="button1" />
<input type="submit" value="button 2" name="button2" id="button2" />
<input type="submit" value="button 3" name="button3" id="button3" />

At the server, you can check if, say, button 2 was clicked like this:

If Request.Form("button2") <> "" Then
  ' handle button 2
End If

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old August 5th, 2005, 09:37 AM
Authorized User
 
Join Date: Jun 2005
Posts: 42
Thanks: 0
Thanked 1 Time in 1 Post
Default

Let say that I have 4 submit buttons. And each button submit to a separate form within the asp page. In the
if request.form(button1)<>"" then
  What code goes here? Can I say: "<form action=testpg1.asp method=POST id=form1 > "

end if

arnniema
 
Old August 7th, 2005, 07:55 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Is each button placed in a different form with a different ASP action page? Or is each button posting to the same page?

Either way, the code I showed you enables you to determine what buttons is clicked.

If you want to have one form (e.g. one set of <form> tags) with different actions, you need to use JavaScript to change the action attribute when the button is clicked....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: I Think I Smell A Rat by The White Stripes (Track 11 from the album: White Blood Cells) What's This?
 
Old August 9th, 2005, 07:52 PM
Authorized User
 
Join Date: Jun 2005
Posts: 42
Thanks: 0
Thanked 1 Time in 1 Post
Default

All the button are in the same form. That is why I want to submit to a separate for from the form that has all the buttons. Please help me on this!!!

arnniema
 
Old August 10th, 2005, 12:52 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:That is why I want to submit to a separate for from the form that has all the buttons
I am not sure I understand this. Can you elaborate a bit on what you're trying to do? Maybe give an example or so?


Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old August 16th, 2005, 05:54 AM
Registered User
 
Join Date: Aug 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<html>
<head>
<script type="text/javascript">
function f_action1()
{
var x=document.forms.Form1
x.action="action1.asp"
x.submit()
}
function f_action2()
{
var x=document.forms.Form1
x.action="action2.asp"
x.submit()
}
function f_action3()
{
var x=document.forms.Form1
x.action="action3.asp"
x.submit()
}
function f_action4()
{
var x=document.forms.Form1
x.action="action4.asp"
x.submit()
}
</script>
</head>
.......
.......
......
<form name="Form1" action="generalaction.asp">
......................................
<input type="submit" value="button 1" name="button1" id="button1" onclick="f_action1()" />
<input type="submit" value="button 2" name="button2" id="button2" onclick="f_action2()"/>
<input type="submit" value="button 3" name="button3" id="button3" onclick="f_action3()"/>
<input type="submit" value="button 3" name="button3" id="button3" onclick="f_action4()"/>
........
......
</form>
</body></html>

I think this is ,what you want?

 
Old August 16th, 2005, 10:54 AM
Authorized User
 
Join Date: Jun 2005
Posts: 42
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thank you very much! That helps...

arnniema





Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple forms one submit x_ray Classic ASP Basics 7 January 3rd, 2006 07:12 PM
cant submit forms rashmid PHP How-To 3 May 29th, 2005 04:34 PM
cant submit forms rashmid HTML Code Clinic 1 May 24th, 2005 05:33 AM
document.forms[0].submit()-not function?? junemo JSP Basics 0 April 27th, 2004 12:40 AM





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