bradderick
asked on
passing url variable by submitting a form
Hi All,
Think my brain might be a bit fried but is there an easy way to add on a url variable (ie searchresults.cfm?variable =1) when you want to submit a form to itself or do you have to pass through a processing page that cflocation's you back to the form you are submitting.
I know about <form name="searchrefine" action="#cgi.script_name#? variable=1 " method="post">
but i want to pass values that the user is inputting inside the form so we don't actually have them yet to forward!
Cheers,
Brad
Think my brain might be a bit fried but is there an easy way to add on a url variable (ie searchresults.cfm?variable
I know about <form name="searchrefine" action="#cgi.script_name#?
but i want to pass values that the user is inputting inside the form so we don't actually have them yet to forward!
Cheers,
Brad
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I didnt use a input type submit - cos i want to control the submission of the form
if i have it as : input type="submit" - then it wont serve my purpose
so u'll have to keep it as a normal image tag & then use the javascript to carry on .....
if i have it as : input type="submit" - then it wont serve my purpose
so u'll have to keep it as a normal image tag & then use the javascript to carry on .....
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the quick follow up guys.
It looks like form action=get seems to be the way to do this. I'll go have a read up on it as have been using post till now. All the time i learn new stuff, it just allows me to see how much there is yet to go!
Thanks for the info about the form as structure, it hadn't occured to me. Will be very useful.
Going to spread points again!
Cheers,
Brad
It looks like form action=get seems to be the way to do this. I'll go have a read up on it as have been using post till now. All the time i learn new stuff, it just allows me to see how much there is yet to go!
Thanks for the info about the form as structure, it hadn't occured to me. Will be very useful.
Going to spread points again!
Cheers,
Brad
Thnx for the "A"
CJ
CJ
brad- one more note. actually it is preferred to use action="get" when searching, this way the user can bookmark the search results if they want to. if you use post and they bookmark the search results page, it is likely they will get an error (unless you plan for it), and if not an error, they won't get the results they bookmarked.
i don't always follow that methodology because I'm lazy at times (not that its hard to change "post" to "get" but that i would need to go replace all my form. with url. and its not a simple s&r all the time), but its worth doing just because of that.
i don't always follow that methodology because I'm lazy at times (not that its hard to change "post" to "get" but that i would need to go replace all my form. with url. and its not a simple s&r all the time), but its worth doing just because of that.
ASKER
thanks for all the excellent input, didn't know that substand and will certainly come in useful.
just for the record for anyone else that reads this thread down the line, referring to:
http://www.houseoffusion.com/cf_lists/cache/4/22/22133.htm
you can't use method="get" with a cfform tag, has to be a regular form tag OR you have to pass to an intermediate page that will append the url variables using cflocation=
Cheers,
Brad
just for the record for anyone else that reads this thread down the line, referring to:
http://www.houseoffusion.com/cf_lists/cache/4/22/22133.htm
you can't use method="get" with a cfform tag, has to be a regular form tag OR you have to pass to an intermediate page that will append the url variables using cflocation=
Cheers,
Brad
Brad, that last bit sounds a little too complicated. I think you would only have to test for the existence of a form field - letting you know that the user is coming from the page where they've entered criteria - and then use a few lines of code to move form variables to url scope:
<cfif isdefined("form.search_cri teria")>
<cfscript>
for(key in form){
if(NOT isDefined('url.#key#') AND NOT key IS "FIELDNAMES"){
SetVariable("url.#key#",tr im(evaluat e("form['# key#']"))) ;}}
</cfscript>
</cfif>
If you put the preceding code at the top of your search results page, you could then use either form or url variables as your incoming search criteria.
<cfif isdefined("form.search_cri
<cfscript>
for(key in form){
if(NOT isDefined('url.#key#') AND NOT key IS "FIELDNAMES"){
SetVariable("url.#key#",tr
</cfscript>
</cfif>
If you put the preceding code at the top of your search results page, you could then use either form or url variables as your incoming search criteria.
ASKER
Would i be able to stick that ONCLICK="javascript:callme
Cheers,
Brad