Jump to content
Sign in to follow this  
vchris

Form submission

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>...

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
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.

Share this post


Link to post
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! :)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

I hear you, I rarely use JS for form validation anymore. I usually process the form on the same page and just postback error messages as html. I find it is much nicer.

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...