|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
CFFORM with method="GET"?
Author: James Blaha
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:22133#111720
CFFORM Workaround to achieve URL variables in a METHOD = "GET" Simulation.
Unfortunately the CFFORM tag does not support the attribute for METHOD. The
default METHOD is POST this email has the information for a workaround if you
still want to use CFFORM without having to use a regular FORM tags and write out
all the JavaScript for field validation.
1. Form page that pass’s all the variables needs to be setup with all the proper
“cfparam" tags for all the fields being used. Data will be sending to an
intermediate conversion template for the POSTED variables.
(A. Sending Template with your CFFORM)
<!--- Note: There are 10 search options available. --->
<!--- 1. ---> <cfparam name="ReqNo" default="">
<!--- 2. ---> <cfparam name="FirstName" default="">
<!--- 3. ---> <cfparam name="LastName" default="">
2. Intermediate Template:
This template needs to capture all the variables and pass them using a CFLOCATION
tag which will automatically pass the variables to the desired location e.g. a
dynamic query search page via the URL. This template doesn’t need anything fancy
and at minimal without error handling the code below will achieve the desired
results.
(B. Intermediate Template)
<CFOUTPUT>
<CFLOCATION
URL="ResultSet.cfm?ReqNo=#TRIM(urlencodedformat(FORM.ReqNo))#&FirstName=#TRIM(urlencodedformat(FORM.FirstName))#&LastName=#TRIM(urlencodedformat(FORM.LastName))#&ApplicationType=#TRIM(urlencodedformat(FORM.ApplicationType))#&Status=#TRIM(urlencodedformat(FORM.Status))#&APPLIED_DATE=#TRIM(urlencodedformat(FORM.APPLIED_DATE))#&Desired_Position=#TRIM(urlencodedformat(FORM.Desired_Position))#&SalaryExpectedYR=#TRIM(urlencodedformat(FORM.SalaryExpectedYR))#&ApplicantStatus=#TRIM(urlencodedformat(FORM.ApplicantStatus))#&HR_Results=#TRIM(urlencodedformat(FORM.HR_Results))#&UserRights=#TRIM(urlencodedformat(FORM.UserRights))#">
</CFOUTPUT>
3. One modification to the receiving template, at the beginning you may want to
convert your URL to FORM variables if you’re using a dynamic loop to pass those
values to a next template or your test code is just using FORM variables.
(C. Dynamic Query Template)
<!--- Note: There are 10 search options available. --->
<!--- 1. ---> <CFSET FORM.ReqNo = URL.ReqNo>
<!--- 2. ---> <CFSET FORM.FirstName = URL.FirstName>
<!--- 3. ---> <CFSET FORM.LastName = URL.LastName>
4. Why all the trouble you ask? If a dynamic query template is being used to
output items where you may want to have the option to delete or modify an
observation of the output upon that event if you reload the referring page from
your action page IE will prompt the user with a security alert. This is the
bypass around this IE bug.
(D. Action Template)
SQL DELETE FROM IMAIL_EMAIL WHERE ID = ‘#FORM.GERRY#’….
<!--- Note: The opener option will refresh the referring pages result set.
--->
<script>
opener.location.reload();
</script>
Below is my best try at a visual to this example where “A” is a search CFFORM
that submits to the Intermediate Template “B” which then relocates and coverts
the FORM variables to URL variables to a Dynamic Query Template “C.” Then if the
user selects a action page to e.g. delete or modify you then open a new window
and run your Action Template “D” which then refresh “C.”
Framed Page Setup
************
* A | B & C *
************
****
* D *
****
I hope this helps if you ever run into this issue. It’s a basic web application
trick but it caused me some pain & loss if time to learn the hard way. When you
really need to use METHOD= “GET” I would say its best to just use FORM tags and
the JS then all this information means nothing.
Regards,
James
Blaha
Author: Everett, Al
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:22133#111713
> Everett, Does that mean I'm stuck with using the regular FORM tag?
I wouldn't consider it being "stuck." I stay far away from CFFORM. I much
prefer to roll my own validation routines.
Author: Bud
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:22133#111657
On 3/6/03, James penned:
>I'm trying to use CFFORM with method="GET" I need to pass my form
>variables via the URL but it seems to be working like a POST.
CFFORM automatically adds method=POST.
--
Bud Schneehagen - Tropical Web Creations
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
buddy@twcreations.com
http://www.twcreations.com/
http://www.cf-ezcart.com/
954.721.3452
Author: James Blaha
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:22133#111642
Everett, Does that mean I'm stuck with using the regular FORM tag?
Regards,
JB
Author: Dave Watts
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:22133#111638
> I'm trying to use CFFORM with method="GET" I need to pass
> my form variables via the URL but it seems to be working
> like a POST.
Straight from the docs:
"The method attribute is automatically set to post; if you specify a value,
it is ignored."
So, if you must send data via the URL, you'll probably want to use a regular
HTML form.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
voice: (202) 797-5496
fax: (202) 797-5444
Author: Everett, Al
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:22133#111630
There is no METHOD attribute for CFFORM.
----- Excess quoted text cut - see Original Post for more -----
Author: James
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:22133#111626
Hello Everyone,
I'm trying to use CFFORM with method="GET" I need to pass my form
variables via the URL but it seems to be working like a POST.
My Code:
<cfform name = "Search" action = "action.cfm" method="GET">
If I get rid of the CFFORM and use a regular FORM it works.
Any ideas?
Regards,
James Blaha
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||