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

Question

Question

Field Rules for a field based on a table response

asked on January 21, 2016

I have a table that lists expenses. Each expense we need to know if there is a receipt, so they would select Yes or No. Outside the table we would like an upload button to show when a user selects yes and a field for them to explain missing receipts when they select No.

Is there coding for this?

Any help would be greatly appreciated.

0 0

Replies

replied on January 26, 2016 Show version history

Hi James,

To show/hide fields outside of a table (based on values inside a table), you need to use JavaScript. If you give your upload button the "upload" class, your explanation field the "explain" class, and the yes/no column field the "receipt" class, the following code should do the trick:

$(document).ready(function(){
  $('.upload, .explain').hide();
  $(document).on('change', '.receipt', function(){
    $('.upload, .explain').hide();
    $('.receipt input:checked').each(function(){
      if ($(this).val() == 'Yes'){$('.upload').show();}
      else if ($(this).val() == 'No'){$('.explain').show();}
    });
  });
});

I assumed you are using a Radio Button for the "receipt" field. If not, you will need to change the selector on line 5.

Let me know if this works for you!

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

Sign in to reply to this post.