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

Question

Question

Using hidden field for lookup causes consecutive lookups

asked on September 22, 2014 Show version history

I have a form that a client wishes to use where two fields might be intermixed by users. In the event either of two fields are filled, they want a lookup to be performed to a database and it uses a stored procedure we configured for the express purposes of having it try both fields until it finds the first response. 

 

I have it currently set up so that on the change of either of these fields, it will take that value, store it to a hidden field, and perform the lookup so that the value in the starting field is able to be overwritten.

 

It was not until the testing user found that if one of those two fields were to be filled in and the new value would be changed, it would perform the lookup again, or in cases where the returned value were empty, it would blank out the fields.

 

I am hoping to find out if anyone can recommend a way to ensure that the lookup is not causing the change to the field, causing it to perform the lookup actions again.

 

I have included below a sample of what my code looks like now for the fields.

.LookupValue {
   display:none;
}
function triggerLookup(fieldValue) {
      $('.LookupValue input').val(fieldValue);
      $('.LookupValue input').trigger('change');
    }
    
    function triggerLookupF1(){
      triggerLookup($('.F1 input').val());
    }
    function triggerLookupF2(){
         triggerLookup($('.F2 input').val());
    }
    
    $('.F1').on('change','input',triggerLookupF1);
    $('.F2').on('change','input',triggerLookupF2);

 

Does anyone have a recommendation on how to handle this so the users will have the functionality they need? The form should never be able to be submitted unless this lookup is performed and these fields are filled, so an instance where it is blanking out the fields is not what they are looking for.

0 0

Answer

SELECTED ANSWER
replied on September 22, 2014

Hey Kenneth,

   If the value in your return in the example above matches the value in your input field then the input value came from your lookup.  You can probably control access to submit based on the return value.

 

-Curtis

0 0

Replies

replied on September 22, 2014

Kenneth,

  If I understand your example you are changing the value of a field based on its own value.  You might have the return of your lookup populate a "ReturnLookup" field and conditionally change the value of your input fields based on that.  You might also want to add a comparison to that new field and your inputs into your triggerLookup to abort the function if not needed.

 

-Curtis

1 0
replied on September 22, 2014

I was thinking this might be the best option, but it's still not exactly a great option. I would like to explore the other options but do appreciate your assistance. 

 

Since the need of the form is to ensure you are only able to proceed if the fields are filled from the lookup, we will not want to incorporate that check though that would effectively only allow the lookup to perform once and not again until starting a new form.

0 0
SELECTED ANSWER
replied on September 22, 2014

Hey Kenneth,

   If the value in your return in the example above matches the value in your input field then the input value came from your lookup.  You can probably control access to submit based on the return value.

 

-Curtis

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

Sign in to reply to this post.