You are viewing limited content. For full access, please sign in.

Question

Question

Forms: hide fields on click java or css?

asked on July 28, 2015

I am looking to hide a field within a checkbox options, when an option is selected from another radio button:

 

 

ID Info:

field to click

field to hide

0 0

Answer

SELECTED ANSWER
replied on July 28, 2015

Here's a more specific example:

$(document).ready(function () {

  $('.radiobutton').change(function () {
    var radiovalue = $('#q1 input:radio:checked').val();
    if (radiovalue == "r1") {
      $('#Field2-0, label[for="Field2-0"]').hide();
      $('#Field2-1, label[for="Field2-1"]').show();
      $('#Field2-2, label[for="Field2-2"]').show();
    } else if (radiovalue == "r2") {
      $('#Field2-0, label[for="Field2-0"]').show();
      $('#Field2-1, label[for="Field2-1"]').hide();
      $('#Field2-2, label[for="Field2-2"]').show();
    } else if (radiovalue == "r3") {
      $('#Field2-0, label[for="Field2-0"]').show();
      $('#Field2-1, label[for="Field2-1"]').show();
      $('#Field2-2, label[for="Field2-2"]').hide();
    } else {
      $('#Field2-0, label[for="Field2-0"]').show();
      $('#Field2-1, label[for="Field2-1"]').show();
      $('#Field2-2, label[for="Field2-2"]').show();
    }
  });
  
});

If r1 is selected, cb1 is hidden. If r2 is selected, cb2 is hidden. If r3 is selected, cb3 is hidden.

2 0

Replies

replied on July 28, 2015 Show version history
0 0
replied on July 28, 2015

This helped me to hide the submit button. You could change the Submit to whatever field #q1223 You want to hide, And the Value to whatever value you specified. I would recommend reversing the Hide and show for you case

 

$(document).ready(function() {
  
  $('.Submit').hide();
  
  $('#q146 input').on('change', function() {
    if ($('#q146 input').val() == "Yes") {
      $('.Submit').show();
    } else {
      $('.Submit').hide();
    }
  });
  
});    

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.