troubleshooting Question

In a Coldfusion <cfif> block, how to set the value of a hidden field?

Avatar of bassman592
bassman592Flag for United States of America asked on
ColdFusion LanguageJavaScript
6 Comments1 Solution19 ViewsLast Modified:
I have a hidden field set up like this on a CFM page:

<input type="hidden" id="downloadFlag" name="downloadFlag" value="0">

Open in new window

I also have a CF variable associated with it:

variables.downloadFlag = form.downloadFlag;

Open in new window

So when the CFM page initially loads , this value is equal to "0". I have a button on the form that sets it to "1" when a download has been requested.  

Then I have this code:

<cfif (variables.downloadFlag eq "1")>
        variables.d_srx = CreateObject('component','mycfcpage');
        variables.d_success  = variables.d_srx.download_files(variables.q_data);
    document.getElementById('downloadFlag').value = 0;

Open in new window

that executes the download function on a CFC page if the value of the flag="1". What I need to do after the function has executed is re-set the value of the flag back to 0. That's what I try to do on the line:

document.getElementById('downloadFlag').value = 0;

Open in new window

but this isn't working. I get no error, yet when I check the value with the inspector after the download, it is still "1".

Is there some CF-specific syntax I need to use to get this field value set back to "0"?


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros