I have a form with some html elements. It has a check box which is by default checked. On click of the submit button it calls the submitForm function Based on the checkbox condition it has to do the action. If the checkbox is Y, then it has to do one form action and if not checked then another action. Using javascript I have checked whether its checked or not. But I am not able to set the coldfusion variable for this. Always it overwrites the variable. Below is the code snippet
This is the ColdFusion variable which is used. This is by default set to Y
<cfset form_condn_var = 'Y'/>
function submitForm(){
if (document.getElementById('Show_Final_Model').checked)
{
form.Show_Final_Model.value = 'Y';
}
else{
<cfset form_condn_var = 'N'/>
}
}
<cfif '<cfoutput>#form_condn_var#</cfoutput>' eq 'Y'>
<form id="form1" action="test.cfm" method="POST" target="testmain">
<cfelse>
<form id="form1" action="<cfoutput>#something#</cfoutput>" method="POST" target="_blank" onSubmit="">
</cfif>
It always set the variable form_condn_var as N and it goes to the else condition of the form irrespective of the condition. . But when I alert the value its comes correctly. I cannot use hidden variable also as the form is not being called initially. Based on the checked condition only it is accessed. Could somebody please tell me why the form_condn_var gets overwritten irrespective of the condition being checked. Or is there any other way I can achieve this?
Thanks in advance
somePage.cfm
, otherwise I want to submit it tosomeOtherPage.cfm
". Does that sound right? – Leigh