Clearing Values from Disabled Choice Control with JavaScript

  • 15 February 2022
  • 0 replies
  • 235 views

Userlevel 5
Badge +19
TOPIC
How to clear values from a disabled Choice control using custom JavaScript.
INSTRUCTIONS
This example outlines two Choice controls, which have been assigned the variables Choice1 and Choice2; where each is a radio button and the choices for Choice2 are "Enter Choice #1", "Enter Choice #2" and "Enter Choice #3".

 

When Choice1 is changed, the JavaScript will remove the value for Choice2, however this can be altered by using an IF statement to determine if the field should be cleared. 
NWF$(document).ready(function()  {  var choice = NWF$("#" +Choice1);  choice.change(function()  {  NWF$("#" + Choice2).find("input:radio[value='Enter Choice #1']").attr("checked",false);  NWF$("#" + Choice2).find("input:radio[value='Enter Choice #2']").attr("checked",false);  NWF$("#" + Choice2).find("input:radio[value='Enter Choice #3']").attr("checked",false); }  );   } );
ADDITIONAL INFORMATION
Normally when a control becomes disabled it retains its value and will return that value to the list when the form is submitted. Using custom JavaScript it is possible to clear the value if a change in selections disables the field.
RELATED LINKS

0 replies

Be the first to reply!

Reply