Skip to main content
Inspiring
July 30, 2008
Question

Submitting a form to itself

  • July 30, 2008
  • 3 replies
  • 539 views
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 .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)>

    This topic has been closed for replies.

    3 replies

    Inspiring
    July 30, 2008
    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
    Inspiring
    July 30, 2008
    The simplest way is to preselect one radio button when you load the page.
    July 30, 2008
    Would a <cfabort> work?