lulu50
asked on
Submit my form
Hi,
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:
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()
{
$("#Submitted").val(1);
$( ".ShowHideAdd" ).show();
$("#SearchForm").attr("action","index.cfm");
$('form#SearchForm').submit();
}
<cfif IsDefined('FORM.SearchForm')>
<cfdump var="#FORM.Status#">
<cfabort>
</cfif>
<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>
<cfelse>
<option value="#QStatus.StatusID#">#QStatus.Status#</option>
</cfif>
</cfoutput>
</SELECT>
<img src="images/SearchtextBoxbtn.png" onClick="SubmitFormSearch()" style="margin-bottom:35px;cursor: pointer;"/>
</FORM>
getting any errors in your console?
ASKER
no no errors but it's not executing this code
<cfif IsDefined('FORM.SearchForm')>
<cfdump var="#FORM.Status#">
<cfabort>
</cfif>
ASKER
if I do isdefined form.selectStatus it works fine
it gives me the value of the selectStatus
but if I do isdefined form.searchform it doesn't work.
so, I am thinking why isn't recognizing my form name
it gives me the value of the selectStatus
<cfif IsDefined('FORM.selectStatus')>
sdddddddd
<cfdump var="#form.selectStatus#">
</cfif>
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#">
<cfabort>
</cfif>
It stands to reason that if:
FORM.selectStatus
is looking for an element called selectStatus inside of the Form
then this;
FORM.SearchForm
Is looking for an element called SearchForm inside the form
You see the problem here?
FORM.selectStatus
is looking for an element called selectStatus inside of the Form
then this;
FORM.SearchForm
Is looking for an element called SearchForm inside the form
You see the problem here?
ASKER
Chris,
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,'Sear chForm')>
or
<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.selectStat us ")>
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.
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,'Sear
or
<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.selectStat
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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:
form.selectStatus
is because you have an element named selectStatus within the form
The reason this doesn't work:
form.SearchForm
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:
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:
form.selectStatus
is because you have an element named selectStatus within the form
The reason this doesn't work:
form.SearchForm
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">
ASKER
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.
gdemaria - your explanation tells my why I can't do it.
ASKER
Thank you
I already explained that SearchForm didn't exist in the form to which you replied:
Clearly you didn't
I know the difference.
Clearly you didn't