0

How do I use JQuery to unselect a choice field?

I'm currently trying to unselect some checkboxes if a previous choice is changed.

For example:

Choice1 is Yes / No. With a dropdown selection. If Yes is selected, Choice2 will show.

Choice2 is Red / Blue / Green. With checkboxes, so people can select multiple.

If I change the choice1 to No, Choice2 is set to disappear. But the choices are still selected behind the scenes.

How do I make it so that when I change Choice1 to No, it'll also unselect all the colours chosen in Choice2?

1

Yes , Here what need to be done is on the first choice .Change function before making it visible or hidden you need to make the Second Choice options unchecked. this can be achieved as given below:

$('#firstChoiceID').change(function()
{
  if($('#firstChoiceID option:selected').text() == "No")
{
//this will make all the check boxes in the page unchecked
$('input[type="Checkbox"]').prop("checked", false);
//This you can use to uncheck the specific checkbox using its id
$('#chkRequestnota').prop("checked", false);
}

});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.