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

Question

Question

If Statement to change value

asked on March 2, 2016

I have a lookup rule filling an input box. I want to change the value if it is equal to a specific number. Here is the code I am using.

$(document).ready(function () { 
    $('#q18 input').change(function() {
  if ($('#q18 input').val() == '288'){
       $('#q18 input').val('226');
  }
  }
})

 

Not sure if it is not working becuase of the lookup rule or not.

0 0

Answer

SELECTED ANSWER
replied on March 2, 2016

It works when I change the #q18 input to #Field18 within the if statement. Also by changing the #q18 input to #q18 on the change function.

$(document).ready(function () {
$('#q18').on('change input', function(){
  if( $('#Field18').val() == '288') {
     $('#Field18').val('226');
         } 

});

 

0 0

Replies

You are not allowed to reply in this post.
replied on March 2, 2016

Your problem is most likely the delay between the javascript running and the input being filled by a lookup rule. The delay is normally small, but the value will not be there when the Form is opened/started, therefore the javascript runs without a value being there.

You are not allowed to follow up in this post.

Sign in to reply to this post.