Workflow Soluiton

 View Only
  • 1.  Component to clear/reset variables

    Posted Mar 28, 2011 09:48 AM

    I have a workflow that presents a web form to a user with a few different checkbox lists. Depending on the state of some other check boxes the user may have clicked the form will present these lists to them using some visible/not visible logic. I also have some free text fields that will display depending on the state of some checkboxes.

    However, this creates a situatuion where a check box can be clicked, revealing a field that can be populated but if the check box is unselected the field is hidden but retains whatever data the user has entered.

    I'm looking for a way to clear variables (both arrays and single values) if they uncheck a checkbox?

    I do not have a programming background so I apologize for my confusing description :)



  • 2.  RE: Component to clear/reset variables
    Best Answer

    Posted Mar 28, 2011 12:20 PM

    You can use Add New Data Element (for one values) or Initialize Data (for many values) to re-initialize elements on the stream back to an empty value.



  • 3.  RE: Component to clear/reset variables

    Posted Mar 28, 2011 02:52 PM

    Ok reecardo...thank you for those options but let's expand the scenario.

     

    Let's say I have a checkbox called 'Cell Phone Required', if they check it a text box becomes visible called 'Area Code' and they can type in the area code.

    Then they decide they have made a mistake and a cell phone is not required so they uncheck the 'Cell Phone Required' checkbox and the 'Area Code' text object is then hidden or set to visible=false.

    How could I then call a routine to clear the area code variable only if the checkbox is not checked?



  • 4.  RE: Component to clear/reset variables

    Posted Mar 28, 2011 04:05 PM

    The Initialize Data component seems to work well (I still need to know how to do the above) for single text variables. However for the CheckBoxList variable it does not clear out the values (items)?



  • 5.  RE: Component to clear/reset variables

    Posted Mar 29, 2011 06:50 AM

    You could write a custom onclick event to wipe out any values. I've done some posts on how to write custom javascript given click events of buttons/checkboxes.

     

    In this case, something like the following (untested):

    1. Make the Control ID of the area code textbox (or whatever needs to be cleared out)  "yadda" (no dbl quotes)

    2. Make the Control ID of the checkbox "blah" (no dbl quotes)

    3. For the checkbox, add a AttributeKeyValuePair custom event to the Custom Events in Functionality / Behavior

    Make the event onclick, and add the event handler script as follows:

    //BEGIN SCRIPT

    var textbox = document.getElementById('yadda');

    var checkbox = document.getElementById('blah');

    if(!checkbox.checked)

    {

    textbox.value = "";

    }

    //END SCRIPT



  • 6.  RE: Component to clear/reset variables

    Posted Mar 30, 2011 10:29 AM

    Thanks reecardo, the initialize data component worked.....my mistake was not having an output path for all options in the variable I was checking against!!!



  • 7.  RE: Component to clear/reset variables

    Posted Mar 30, 2011 11:05 AM

    Not sure why....here's what I did

     

    I have a checkbox component and I gave it a control ID of 'blah' no quotes.

    I have a textbox component and I gave it the control ID of 'yadda' no quotes.

     

    On the checkbox component I added a AttributeKeyValuePair custom event to the Custom Events in Functionality / Behavior, set it to 'onclick' and in the event handler window I typed:

    //BEGIN SCRIPT

    var textbox = document.getElementById('yadda');

    var checkbox = document.getElementById('blah');

    if(!checkbox.checked)

    {

    textbox.value = "";

    }

    //END SCRIPT

    I also checked of the 'Post Form on Value Change' checkbox but it did not clear the textbox variable?

     

    I managed to find a way to clear the variable using a match component in a visible dynamic model that uses a initialize variable component depending on the value of a dropdown list but cannot figure out how to do the same using the value of a checkbox? Does a checkbox not return a value of either true or false?



  • 8.  RE: Component to clear/reset variables

    Posted Mar 30, 2011 11:50 AM
      |   view attached

    I'm attaching a webforms project with my script and it appears to be functioning). Just rename the .zip to .package

    I was seeing wierd behavior when I cut and pasted my script to test it out. Then I added some debug alerts to see what the problem was, and I had split a command with a carriage return. Then I just manually made it well formed.

    To test it I put some text in the text box, then checked the checkbox (no change), then unckecked (the textbox value clears)

    Attachment(s)

    zip
    WebFormsProject1_0.zip   2.04 MB 1 version


  • 9.  RE: Component to clear/reset variables

    Posted Apr 01, 2011 11:13 AM

    Sorry Reecardo, I thought I was good, this works to clear a simple TextBox component value but not a CheckBoxList?

     

    I posted a new discussion.