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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple buttons on one form

Status
Not open for further replies.

sliver

Programmer
Nov 16, 2000
23
US
I have a real basic query and output for a form my problem is that the query could bring back upwards of 200 records and I only want to display 20 per page and at the bottom of each page I want to either
A: submit and make a report from the names I have chosen
or
B: keep the names I have chosen and see the next 20 to see if I want to add one of them.

I dont even know if it is possible to have two buttons on a form that preform different actions but if it is i cant find the code anywhere.
<CFquery datasource=&quot;DS&quot; name=&quot;Qname&quot;>
select name, id from table
</CFQUERY>
<FORM>
<cfoutput query=Qname>
<input type=&quot;checkbox&quot; name=&quot;include&quot; value=&quot;#id#&quot;>#name#
<CFOUTPUT>
<INPUT TYPE=&quot;submit&quot; VALUE=&quot;make a report&quot;>
</FORM>

thanx in advance
 
I think this is what you want:
<form action=xyx.cfm&quot; name=blabla>
custom code goes here
<input type=submit name=submit value=buttonvalue1>
<input type=submit name=submit value=buttonvalue2>
</form>



Then on the xyx.cfm page, you would have something like:

<cfif #form.submit# EQ 'buttonvalue1'>
custom code goes here
<cfelseif #form.submit# EQ 'buttonvalue2'>
custom code goes here
</cfif>

Hope this is what you need. The only dumb questions are the ones that are never asked
 
Hello All,
I think that the solution to the problem given by twcmam is just great.Your problem is solved using CFML.

I just to wanted show another possible solution that solves your question but using Javascript:
Here is the code:

You should put this code into the head section of your form page:

<html>
<head>
<title>YOUR FORM PAGE</title>
<script language=&quot;JavaScript&quot;>
<!----------------------
function send(ref_form,action_page)
{
ref_form.action=action_page;
ref_form.submit();
}
//---------------------->
</script>
</head>
<body>
<form>

All of your form code goes here.

<input type=&quot;button&quot; name=&quot;button1&quot; value=&quot;Submit 1&quot; onclick=&quot;send(this.form,'actionpage1.cfm')&quot;>
 
<input type=&quot;button&quot; name=&quot;button2&quot; value=&quot;Submit 2&quot; onclick=&quot;send(this.form,'actionpage2.cfm')&quot;>
</form>

Instead of using two submits, I put two buttons in the form and I use the &quot;onclick&quot; event handler for every button in the form,and pass the form and the action page to the javascript function.
This is a more complex code than twcman wrote and you must have two differents action pages for the form,but it's another way to solve the same problem,using a client-side language such as Javascript.

I hope this helps...

Kind Regards


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top