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

Discussion

Discussion

Forms - Run javascript when database look up is complete

posted on February 9, 2015

All the triggers for javascript appear to be related to user interactions, blur, click, etc. Is there any way to trigger on a database lookup? For example, after a database lookup updates a hidden field?

0 0
replied on February 11, 2015

You can manually tell the system there was a change using JavaScript. 

The syntax is:  $('.myClass select').trigger('change');

select is used for a drop-down field. If you are using a single line field, use input instead.

If the look-up you are referring to is performed by Javascript, just insert this line at the end of that function. If the look-up is performed by Forms, set this to run after a the input for the look-up is changed, then add a small delay. 

 

Good luck! 

0 0
replied on February 11, 2015

I think that is my problem, how do I set something to run after the input has changed when the system doesn't know when it has changed. I suppose I can do a loop that checks for data in the field and once there is data then it executes my javascript.

0 0
replied on February 10, 2015

Perhaps you can use on change to monitor the hidden field?  So when its not empty then perform the java function?

 

onchange

 

The event occurs when the content of a form element, the selection, or the checked state have changed (for <input>, <keygen>, <select>, and <textarea>)
0 0
replied on February 10, 2015 Show version history

That onchange action doesn't appear to be supported in forms. Sure would be nice though. Javascript doesn't debug well so I never know what is going on, just seems to either work or not work.

Here is how I tried to implement it, even a manual change is not considered a change with this code.

$(document).ready(function () {

  
    $('.sqlcomplete').onchange=function(){
     
       document.getElementById("links").innerHTML = $('.sqlcomplete input').val();
         
  }
  
});

This code works just fine when someone blurs the field, but not when the look up activity accesses the field.

 

$(document).ready(function () {

  	$('.sqlcomplete').on('blur', 'input', creatlinks);

    
    function creatlinks() {
      
       document.getElementById("links").innerHTML = $('.sqlcomplete input').val();
      
    }
});

I just found that on.('change', 'input', createlinks) is another option but still waits for a user to change the field, not a system change.

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

Sign in to reply to this post.