Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Adding multiple search buttons to a form

Posted on 2002-05-07
4
Medium Priority
?
143 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 400 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

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…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

972 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