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

Question

Question

Hide Form field based on a returned value

asked on May 8, 2015

I need to be able to hide a field on a form when the value returned is NULL.  The fields a populated based on a database lookup and there are times when a value of NULL would be the only option.  I've added a screenshot of the form's fields as well as the JQuery I'm trying to configure to hide the field based on a returned value of NULL.

 

 

0 0

Answer

SELECTED ANSWER
replied on May 8, 2015 Show version history

Hi Nathan,

The field rules won't allow you to show or hide a field that checks against itself. You can use this Javascript

$(document).ready(function () {
  $(document).on('lookup change', nullfunction);

  function nullfunction() {
    if ($('#q13 select').val() == "NULL") {
      $('#q13').hide();
    } else {
      $('#q13').show(); 
    }
  }
});

First, use 'lookup change' instead of just 'change' since the fields are set with a lookup. Also, when referencing fields by their ids, you need to use '#' and not '.' Lastly, for drop down fields, they are select elements, not input elements.

Regards

0 0
replied on May 8, 2015

Alex,

 

That worked perfect!  Thanks for your help.

0 0

Replies

replied on May 8, 2015

Have you tried using regular Field Rules?

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

Sign in to reply to this post.