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

Question

Question

Populate each row field based on dropdown value.

asked on June 28, 2021

Hi,

I have a table with two columns, I want to populate the Hidden Type column with a certain value based on what was selected on the drop down.  see the code below to get some guidance, how do I cater per row.

$(document).ready(function(){
   $('form').click(function(){
  
  
    var TraineeStatus = 'select[id^=Field67\\(]';
	var TraineeType    = 'select[id^=Field159\\(]';
	 $(TraineeType).each(function(){

    var index = $(TraineeType).index(this);
      
      if ($(TraineeStatus).eq(index).val() == 'Requested')
	     {TraineeType = $('Approved').val();}
	  else if ($(TraineeStatus).eq(index).val() == 'Scheduled')
	     {TraineeType = $('Planned').val();}
      else if ($(TraineeStatus).eq(index).val() == 'Inprogress')
	     {TraineeType = $('Actual').val();}
      else if ($(TraineeStatus).eq(index).val() == 'Completed')
	     {TraineeType = $('Actual').val();}
      else if ($(TraineeStatus).eq(index).val() == 'Absconded')
	     {TraineeType = $('Actual').val();}
      else if ($(TraineeStatus).eq(index).val() == 'Resigned')
	     {TraineeType = $('Actual').val();}
      
    });
  });
});

 

0 0

Answer

SELECTED ANSWER
replied on July 2, 2021

Hi Reneilwe, 

 

My apologies, I had an error in my function. Please try the function below.
 

IF(INDEX(Trainee_Allocation.Training_Status, ROW()) = "Approved", "Requested",
IF(INDEX(Trainee_Allocation.Training_Status, ROW()) = "Scheduled", "Planned", "Actual"))

 

I shortened your function since we do not need to check for most of the values when it is "Actual", only when it won't be. 

0 0

Replies

replied on June 29, 2021

Hi, 


Not sure how to use JS but here is an example of a function which can accomplish your desired behavior.

 

IF(INDEX(TableName.ColumnName, ROW()) = "Planned", "Planned", IF(INDEX(TableName.ColumnName, ROW()) = "Scheduled", "Scheduled", IF(INDEX(TableName.ColumnName, ROW()) = "InProgress", "Completed")))

 

You can continue to nest the IF statements until you have covered all possible options.

0 0
replied on July 2, 2021

Hi Gillberto,

 

Thank you for your response, I tried your way I am getting an error saying "Calculation does not contain the correct number of input parameters"

 

IF(INDEX(Trainee_Allocation.Training_Status, ROW()) = "Approved", "Requested",
IF(INDEX(Trainee_Allocation.Training_Status, ROW()) = "Scheduled", "Planned",
IF(INDEX(Trainee_Allocation.Training_Status, ROW()) = "Inprogress", "Actual",
IF(INDEX(Trainee_Allocation.Training_Status, ROW()) = "Completed", "Actual",
IF(INDEX(Trainee_Allocation.Training_Status, ROW()) = "Absconded", "Actual",
IF(INDEX(Trainee_Allocation.Training_Status, ROW()) = "Resigned", "Actual"))))))

0 0
SELECTED ANSWER
replied on July 2, 2021

Hi Reneilwe, 

 

My apologies, I had an error in my function. Please try the function below.
 

IF(INDEX(Trainee_Allocation.Training_Status, ROW()) = "Approved", "Requested",
IF(INDEX(Trainee_Allocation.Training_Status, ROW()) = "Scheduled", "Planned", "Actual"))

 

I shortened your function since we do not need to check for most of the values when it is "Actual", only when it won't be. 

0 0
replied on July 4, 2021

Hi Gilberto, 

 

Thank you so much this worked.

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

Sign in to reply to this post.