How do I reset Session Variables (radio buttons) when Reset button is selected?

Posted on 2006-04-04
Last Modified: 2013-12-24
I have a flash form with radio boxes.  The user must select a radio button before submitting the form (required="yes").  If they don't fill out, complete, or check a required field they receive the flash messagebox telling them that it cannot be submitted because field(s) xxx are not completed.  All works well!!!

However, when the user clicks a reset button (<cfinput type="reset" ...>) then fills out all of the required fields with the exception of the radio button they are able to submit the form because the reset does not clear out the original selection for the radio button.

If I use a <CFDUMP var="#form#> I see that in the first instance the variable is not even initialized and that is whay it is being caught by the <cfinput type="radio"...required="yes"...>.  When I submit the form after a radio button has been clicked then the reset button is pressed I see that the variable is initialized using CFDUMP and that it is an empty string.

Is there a way to use the onclick function of the reset button to kill it (such as structclear(inputname)) so that the user cannot submit without selecting the radio button again?
Question by:DRSLT
    LVL 9

    Expert Comment

    You can extend flash forms by using the <cfformitem type="script"> tag and you could then write a function that would check the state of the actual control on the flash form.  I'm not the best at actionscript so I might have a mistake here that someone else will catch but something like:

    <cfformitem type="script">
    function checkRadio()
    if(radioControlName.selectedData != '')
          return true;
          alertMsg('Please select one of the radio buttons');
                    return false;

    Then onSubmit just 'return checkRadio()'.

    I probably have something wrong so hopefully someone that is better with actionscript can help.  Here is some background info which helps with the concepts tho:

    Alternately you could write a function to set the value back to whatever the default was manually and add the call to that function to the onClick for the reset button.  That way it would be in the initial state.

    Hope that helps some.
    LVL 1

    Author Comment

    Thanks for the response.

    I thought about using this sort of tactic as a last resort, but I would like to just be able to reinitialize all of the controls on the page so that the <...required = "yes"...> attribute of the control which is built into flash forms could simply do what it is supposed to do.  My other 'last resort' option was to submit the form with a reset button and reload the page and then if the form value of the reset button is present I can then clear all session variables using structclear and continue loading the form resulting in the empty form being redisplayed.
    LVL 1

    Accepted Solution

    Write your own validation and forget about the validate attribute when using radio buttons.  It is the only good way!
    LVL 1

    Author Comment

    I wanted to split the points on this but it didn't work.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
    One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now