Solved

Adding multiple search buttons to a form

Posted on 2002-05-07
4
133 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:SBennett
Comment Utility
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
Comment Utility
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:
SBennett earned 100 total points
Comment Utility
Yes, that is exactly what I already suggested, just without the examples. =)
0
 

Author Comment

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

Thanks for the help!!!!!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
URL redirect 4 47
Internal DNS Zone Issue 13 51
apply ddos protection on all network interface 2 50
Setting Up Local Lan Web Server 1 14
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
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 …
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now