Solved

Adding multiple search buttons to a form

Posted on 2002-05-07
4
137 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

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

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

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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