lookup dropdown change event in table-dv.js

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
GeneSD
Posts: 4
Joined: 2016-01-12 15:08

lookup dropdown change event in table-dv.js

Post by GeneSD » 2017-03-24 03:01

appgini ver: 5.60

I am trying to hide some form elements based on a selection via a lookup dropdown. Below is what I have tried and it does not work.

table-dv.js file content:

jQuery( document ).ready(function( $ ) {
console.log("Help Me"); // this works...


$("#fk_project").on("change", function() {
console.log("test"); // this does not.
$('#nn_other').hide();
});

});

GeneSD
Posts: 4
Joined: 2016-01-12 15:08

Re: lookup dropdown change event in table-dv.js

Post by GeneSD » 2017-03-25 13:54

For those of you looking to solve the problem that I had here is the answer for the table-dv.js magic file.
This will only turn them off you will have to write some code to turn them back on if a different selection is made.

Code: Select all

jQuery( document ).ready(function( $ ) {

   jQuery('#fk_project-container').change(function(){ 

   var cnt=document.getElementById('fk_project').value;//dropdown selected/changed value
   
  	if(cnt==1){
  	    //as you can see from the code below you can hide parent elements as well which would hide multiple controls at once
  	    $('#nn_training0').parent().parent().parent().hide();
		
	    $('#nn_warfare').parent().parent().hide();
	
	    $('label[for="nn_other"]').hide();
	    $('#nn_other').hide();
	
	    $('#nn_tools').parent().parent().hide();
   		
	
	}else if (cnt==2) {
	   
	   //and hide other controls if a different selection is made.
	   $('label[for="d_div"]').hide();
	   $('#d_div').parent().hide();
	   
	   $('label[for="d_role"]').hide();
	   $('#d_role').parent().hide();
	   
	
	   $('#d_training').parent().parent().hide();
	   
	   $('#d_inc').parent().parent().hide();
	   
	   $('#d_used').parent().parent().hide();
	   
	}

  });
});
 

Post Reply