Jump to content

Form submission


vchris
 Share

Recommended Posts

There's something I don't understand about this issue.I have a form on header_e.cfm

<form action="search_e.cfm" method="post" name="searchText">Search RET Documents<br /><input type="text" name="keywords" size="30" /> <input type="submit" value="Search" name="Operation1" onclick="return validateSearchText();" /><br /><input type="radio" name="cri" value="or" checked="checked" />Any Match<input type="radio" name="cri" value="and" />Exact Match</form>

As you can see it is submitted to search_e.cfm. On search_e.cfm I search the db for the search string. The problem if I'm on main_e.cfm and do the search in the header, the search page will not get the "keywords" string. When I print the value of form.keywords I get blank. If I do my search in the header of search_e.cfm I get the correct results and the search string is printed out with form.keywords.

...<cfset kwords= ReplaceNoCase(keywords, " ", "%,%", "ALL")><cfset kwords= "%" & kwords & "%"><cfoutput>kwords: #kwords#<br />form.keywords: #form.keywords#<br />form.cri: #form.cri#<br />form.submit: #form.operation1#</cfoutput>...

Link to comment
Share on other sites

  • 2 weeks later...

Sorry its been a week since your post.have you resolved the issue?have you tried use the "get" method and using url.kwords versus form.kwords?Otherwise, I am not sure I complete understand the issue. Is header_e.cfm an include file throughout your site like on main_e.cfm?

Link to comment
Share on other sites

It's not actually my site, I am just trying to fix some issues. I'll try the get method and url.kwords instead. I'll let you know how it goes.EDIT: Yes header_e.cfm is an include file on all pages. I forgot to mention 1 thing, when I print out the values of my form when submitting from the header_e.cfm (only when different than search_e.cfm) I get the cri value and submit value but not the keywords value. So some of the form data is being sent except for that keyords field. I have checked many times the field names.I just tried with get and url and still the same problem.

Link to comment
Share on other sites

RESOLVEDThe error was in the javascript that the previous programmer programmed. He had:

function validateSearchText() {			if (document.searchText.keywords.value == "") {				alert("Please enter a search string");				return false;			}			document.searchText.submit();			document.searchText.keywords.value = "";			return true;		}

document.searchText.keywords.value = ""; erased the field before the data was sent. I commented that line out and works fine! :)

Link to comment
Share on other sites

sweet - I know there are good reasons for using javascript for form submission (client side validation) but with the last site I took over I had tons of these issues. Just another place to track a problem that you don't think of first. This is why I use CFMX7 Flash Forms when possible.:)Glad you found the error, and resolved it.

Link to comment
Share on other sites

Same here with validation without JS. It's a lot more secure validating server side and you don't have those annoying pop-ups. I'm not crazy about JS also...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...