Submit my form

Posted on 2014-03-14
Last Modified: 2014-03-14

for some reason my form is not getting submitted.  

I can't get it to submit my form.

I have an image that calls Jquery and submit the form.

This is my code:

function SubmitFormSearch()
	$( ".ShowHideAdd" ).show();

<cfif IsDefined('FORM.SearchForm')>
<cfdump var="#FORM.Status#">

<FORM id="SearchForm" METHOD="POST" name="SearchForm" ACTION="<cfoutput>#ActionURL#</cfoutput>"> 

 <SELECT name="selectStatus" id="selectStatus">
           <cfoutput query="QStatus">
			<cfif (isdefined('FORM.Submitted') and (#FORM.selectStatus# eq #QStatus.StatusID#))>
			<option value="#QStatus.StatusID#" selected="selected">#QStatus.Status#</option>
			<option value="#QStatus.StatusID#">#QStatus.Status#</option>

    <img src="images/SearchtextBoxbtn.png" onClick="SubmitFormSearch()" style="margin-bottom:35px;cursor: pointer;"/>


Open in new window

Question by:lulu50
LVL 32

Expert Comment

by:Big Monty
ID: 39929307
getting any errors in your console?

Author Comment

ID: 39929312
no no errors but it's not executing this code

<cfif IsDefined('FORM.SearchForm')>
<cfdump var="#FORM.Status#">

Open in new window


Author Comment

ID: 39929483
if I do isdefined form.selectStatus it works fine
it gives me the value of the selectStatus

<cfif IsDefined('FORM.selectStatus')>
<cfdump var="#form.selectStatus#">

Open in new window

but if I do isdefined form.searchform it doesn't work.
so, I am thinking why isn't recognizing my form name

<cfif IsDefined('FORM.SearchForm')>
<cfdump var="#FORM.selectStatus#">

Open in new window

LVL 42

Expert Comment

by:Chris Stanyon
ID: 39929552
It stands to reason that if:


is looking for an element called selectStatus inside of the Form

then this;


Is looking for an element called SearchForm inside the form

You see the problem here?

Author Comment

ID: 39929571

I know the difference.

Here is my question:

why I can't get the value of the FORM.selectStatus  if I say

<cfif StructKeyExists(Form,'SearchForm')>
<cfif isdefined("form.SearchForm")>

but when I say (this it takes me straight to my field value without validate the form submission)
<cfif isdefined("form.selectStatus ")>
it works fine and display my value

so, if I have a value in the form.selectstatus that means the form has been submitted and
if the form has been submitted why my Isdefined("form.SearchForm") will not work.
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

LVL 39

Accepted Solution

gdemaria earned 500 total points
ID: 39929601
When you submit a form, a structure key will be created for each input/select/checkbox, etc inside of that form.     "SearchForm" is not the name of one of the input tags within that form.    SearchForm is the name of the form, I do not believe that submitting a form creates a form key for the name of the form, what value would it have?

You can test this by putting this at the top of your page and submitting..

<cfdump var="#FORM#">

This will show you all the input values created on your form submit, I don't think you will see the name of the form among the values.

I think it would be perfectly Ok to test for the select tag name (the thing that works for you).

What I usually do is to test for the button or submit input tag...

<input type="Submit" name="doSave" value="SAve It " >

In this case, I would test for IsDefined("Form.DoSAVe")

Since you are doing an image, you can use type="button" and test for  Form.doSave.x  

Again, you can using <cfdump var="#form#"> to see what values are created when you submit
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39929629
Hey lulu,

I don't know ColdFusion specifically so I'm working off of common sense here, and the way that HTML works in general. The reason this works:


is because you have an element named selectStatus  within the form

The reason this doesn't work:


is because there is no element named SearchForm within the form - it is the form's ID, so never gets passed back to the server - ever!!

In your jQuery, you seem to be setting the value of #Submitted to 1, but there is no element with that ID in your form. You need to create it, and also give it a name. Then you check that to see if you form has been submitted:

<input type="hidden" id="Submitted" name="Submitted">

Open in new window


Author Comment

ID: 39929661
Chris - I do have an element called Submitted in my form but I did not included in my code above because that wasn't my issue.

gdemaria - your explanation tells my why I can't do it.

Author Closing Comment

ID: 39929663
Thank you
LVL 42

Expert Comment

by:Chris Stanyon
ID: 39929695
I already explained that SearchForm didn't exist in the form to which you replied:

I know the difference.

Clearly you didn't

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question ( on how to make a page show some balloons animate up a page…
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now