Solved

Adding multiple search buttons to a form

Posted on 2002-05-07
4
139 Views
Last Modified: 2013-12-24
I want to create a search page in which the user adds an input field.  If he clicks one button a certain results1.cfm page is retrieved, if he hits another an alternate results2.cfm page is retrieved.  How do I go about this?

I'm guessing that I have to use an 'if' statement based on the button he clicks, i.e. if he clicks button1 action=results1.cfm, if he clicks button2 action=results2.cfm.

Is this possible?
0
Comment
Question by:CTerreri
  • 2
4 Comments
 
LVL 14

Expert Comment

by:Scott Bennett
ID: 6995195
I would have both submit buttons go to the same action page then include the results page based on wich button was pushed.

Example:
____________________________________________
ActionPage.cfm
--------------------------------------------
<cfif isDefined("Form.Button1")>
    <cfinclude template="results1.cfm">
<cfelseif isDefined("Form.Button2")>
    <cfinclude template="results2.cfm>
</cfif>
____________________________________________
Form.cfm
--------------------------------------------

<cfform name="MyForm" action="ActionPage.cfm" method="POST">
<cfinput type="text" name="Input1">
<input type="Submit" name="Button1" value="Button1">
<input type="Submit" name="Button2" value="Button2">
</cfform>
_______________________________________________

Although another possibility is to create a hidden form and use java script to copy the information to the hidden form to the alertnative action page.
Like this:

-----------------------------------------------------
<script language="JavaScript">
function proccessform2()
{
     var Input1 = document.MyForm.Input1;
     document.MyHiddenForm.Input1.value = Input1;
     document.MyHiddenForm.submit();
}
</script>


<cfform name="MyForm" action="results1.cfm" method="POST">
<cfinput type="text" name="Input1" value="">
<input type="Submit" name="Button1" value="Button1">
<input type="Button" onclick="proccessform2();" name="Button2" value="Button2">
</cfform>

<cfform name="MyHiddenForm" action="results2.cfm" method="POST">
<input type="hidden" name="Input1" value="">
</cfform>

---------------------------------------------------------
0
 
LVL 5

Expert Comment

by:nathans
ID: 7001888
There is two ways to do this..

1. JavaScript can change which page it submits too depending on which button you press.

2. You can send the page to a ColdFusion page that then forwards to whichever page you want it to go to.


Nathan
http://www.cftipsplus.com
0
 
LVL 14

Accepted Solution

by:
Scott Bennett earned 100 total points
ID: 7001942
Yes, that is exactly what I already suggested, just without the examples. =)
0
 

Author Comment

by:CTerreri
ID: 7002573
I went ahead and tried the "forwarding" to an intermediate action_page and and it worked fine.

Thanks for the help!!!!!
0

Featured Post

Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question