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

Question

Question

postpone java execution until a field is populated following a view lookup.

asked on October 10, 2014

I have the following JavaScript to fill in some radio buttons using single line fields that are populated with data following a lookup of a stored procedure.  I need to postpone the execution of the functions using case statements until after the view has populated the single line fields.  Can someone Help?

 

$(document).ready(function() {
  $('.checkbox').click(function () {
    
    if($('input[value="yes"]').is(':checked')) //edit the value here to use your own.
       {
       $('.Submit').show();
       }
    else {
      $('.Submit').hide();
    }
  });                  
});
$(function() {
  $(document).ready(function () {
    var value = $('. v_S06grwPlanSub input').val();
    switch (value){
      case "1": 
          document.getElementById('Field179-0').checked = true;
          break;
      case "2":
          document.getElementById('Field179-1').checked = true;
          break;
      case "3":
          document.getElementById('Field179-2').checked = true;
          break;
      case "4":
          document.getElementById('Field179-3').checked = true;
          break;
      default:
        alert(value);
    }
  });
}); 
$(function() {
  $(document).ready(function () {
    var value = $('. v_gpStudyWork input').val();
    switch (value){
      case "1": 
          document.getElementById('Field181-0').checked = true;
          break;
      case "2":
          document.getElementById('Field181-1').checked = true;
          break;
      default:
        alert(value);
    }
  });
}); 
$(function() {
  $(document).ready(function () {
    var value = $('. v_recommendation input').val();
    switch (value){
      case "1": 
          document.getElementById('Field182-0').checked = true;
          break;
      case "2":
          document.getElementById('Field182-1').checked = true;
          break;
      case "3":
          document.getElementById('Field182-2').checked = true;
          break;
      case "4":
          document.getElementById('Field182-3').checked = true;
          break;
      case "5":
          document.getElementById('Field182-4').checked = true;
          break;
      case "6":
          document.getElementById('Field182-5').checked = true;
          break;
      default:
        alert(value);
    }
  });
});

lookup.PNG
lookup.PNG (47.91 KB)
0 0

Answer

SELECTED ANSWER
replied on October 11, 2014

I have solved this problem by rewriting your recommendation for "How to fill checkboxes from a database"  please see the comments on that question for a solution to delaying the trigger of the view.

0 0

Replies

replied on August 15, 2016

I know this is an older question, but I had the same issue with a very complex form and I believe I found an elegant solution. If you have code that you want to run once after a lookup populates a field, either at the beginning or later on based on another action, jQuery has a very handy "ajaxStop" action.

//If after page loads, then this will be in $(document).ready(function(){...
//otherwise, this can be used in any other method or click/change event handler.
$(document).one('ajaxStop',function(){ 
  //Execute your run-once code here
});

This will attach an event that will only run once, that will be run once ajax has completed, which is when the lookup on a field has completed.

1 0
replied on October 10, 2014

you will need to include a timeout statement in there to delay it. I find that for lookup most lookups happen in a half second to a full second. If there is no values in a field you can use a timeout to test a field and retest every so often until you know its filled and then proceed. 

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

Sign in to reply to this post.