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

Question

Question

how to do an action in a collection when a dorpdown field value from the same collection is selected

asked on March 19, 2019

It works only in half, I can get the value change but it seems to do it to all the row in collection and not just for one row

Here my code

$(document).ready(function(){
	$('#q5').hide();
  	$('.cf-collection').change( function (){
  		$('.cf-collection > div').each(function (){
           

          	if ($('#q8 input[value="Yes"]').is(':checked')){
          		if ($(this).find('#q9 select option:selected').val() == 'Autofill Mileage'){		
        			$(this).closest("div").find('#q6 input').val($('#q7 input').val());
        			$(this).closest("div").find('#q6 input').attr('disabled',true);        
        		
                }else{
                    $(this).closest("div").find('#q6 input').val('');
        			$(this).closest("div").find('#q6 input').removeAttr('disabled');
                }
              
          	}         
          
       });
	});
});

 

When the expense is other than "Autofill Mileage" all GL code on all collection added become Blank.

I see that I do not point to the proper collection index

 

I also tried with this code

$(document).ready(function(){
	$('#q5').hide();
  	$('.cf-collection').change( function (){
  		$('.cf-collection > div').each(function (){
           
           $(this).find('#q9 select').change(function(){

          	if ($('#q8 input[value="Yes"]').is(':checked')){
          		if ($(this).find('#q9 select option:selected').val() == 'Autofill Mileage'){		
        			$(this).closest("div").find('#q6 input').val($('#q7 input').val());
        			$(this).closest("div").find('#q6 input').attr('disabled',true);        
        		
                }else{
                    $(this).closest("div").find('#q6 input').val('');
        			$(this).closest("div").find('#q6 input').removeAttr('disabled');
                }
              
          	}
         
       	  });   
          
       });
	});
});

And it did not work at all

I do not figure how to point to the proper Dropdown selector in the collection.

 

I successely doinf an action to the proper row of the collection if I use a radio button field selector in place of a dropdown feild selector

 $(this).find('#q5').click(function(){

 

Any thought?

 

 

 

0 0

Replies

replied on March 19, 2019 Show version history

This kind of thing comes up quite a bit. I wrote up a post a couple of months back that should help point you in the right direction.

https://answers.laserfiche.com/questions/153832/Table-and-Collection-JavaScript-Event-Handlers

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

Sign in to reply to this post.