When I submit a form, instead of submiting it to an action page, I submit it
back to itself, with all the processing taking place before the form/cfform
statement.
Here is the problem that I am running into. I have radio buttons and use
javascript to check that at least one button is checked. Here is my code and it
works :
<script language="javascript">
function validateForm(editProfileForm){
var returnStatus = true;
myOption = -1;
for (i=editProfileForm.profileStatus.length-1; i > -1; i--) {
if (editProfileForm.profileStatus[i].checked) {
myOption = i; i = -1;
}
}
if (myOption == -1) {
alert("Please select active or inactive button.");
editProfileForm.profileStatu.focus();
returnStatus(false);
}
if (returnStatus){
editProfileForm.submit();
}
returnStatus(true);
}
</script>
</head>
<body>
But the problem is that as soon as I click ok in the popup message, it goes
down to the next command, which is checking for the submit button being
selected (below). The page then blows up. How would I stop the page from
continuing after the radio button error ? It seems to work if there is an
action page but submitting the form to itself seems to cause this problem.
<!--- If the submit button is selected, process the page below --->
<cfif parameterExists(form.btnSubmit)>
eightcharacters - 30 Jul 2008 06:46 GMT
GArlington - 30 Jul 2008 11:00 GMT
> When I submit a form, instead of submiting it to an action page, I submit it
> back to itself, with all the processing taking place before the form/cfform
[quoted text clipped - 20 lines]
> editProfileForm.profileStatu.focus();
> returnStatus(false);
Where (AND WHY) did you define a function returnStatus(boolean)?
I guess that you meant returnStatus =false; here...
> }
>
[quoted text clipped - 18 lines]
> <!--- If the submit button is selected, process the page below --->
> <cfif parameterExists(form.btnSubmit)>
Dan Bracuk - 30 Jul 2008 12:50 GMT
The simplest way is to preselect one radio button when you load the page.
Ian Skinner - 30 Jul 2008 14:29 GMT
What version of ColdFusion are you using?
ParameterExists
Description
This function is deprecated. Do not use it in new applications. Use the
IsDefined function.
Determines whether a parameter exists. ColdFusion does not evaluate the
argument.
History
New in ColdFusion MX: This function is deprecated. Do not use it in new
applications. It might not work, and might cause an error, in later
releases.
http://livedocs.adobe.com/coldfusion/6/CFML_Reference/functions-pt249.htm