Jump to content

JS If/Then to Dynamically Copy Value


Recommended Posts

I have 10 text field dropdowns (Material1 - Material10) that correspond with 20 other text field dropdowns (Labor1 - Labor20). 

For each Material, there will need to be 2 corresponding Labor fields. In example, if I choose Aluminum for Material 1, I need to have Labor 1 and Labor 2 be set to Aluminum as well. If Material 2 was glass, I would need Labor 3 and Labor 4 to be set to Glass.

If this can be done without JS, I'm open for it. I can't seem to find a way to set a Value through Rules. I'm not quite skilled enough to get an if/then function going myself. If anyone could get me going in the right direction, I would appreciate it!

Link to comment
Share on other sites

On 7/5/2019 at 5:45 AM, rguardiola1 said:

I'm in the same situation. I need the ability for an If/Then/Else for a calculated field. For example: If a field value if greater than or equal to 0, add these two fields, ELSE don't do a calculation.

Any ideas are welcome.

Thx,

Ruben

You need to use SQL syntax for instance


 

CASE

WHEN ....

THEN ...

WHEN ...

THEN ...

ELSE ...

END

 

Link to comment
Share on other sites

I got it figured out with JavaScript. I appreciate your guys' help, it was a hard question to understand.

var mat1= document.getElementsByName('InsertRecordMat_1')[0];
var mat2= document.getElementsByName('InsertRecordMat_2')[0];

var lab1= document.getElementById('InsertRecordLabor1');
var lab2= document.getElementById('InsertRecordLabor2');

var phase1= document.getElementById('InsertRecordLabor1_Phase');
var phase2= document.getElementById('InsertRecordLabor2_Phase');

mat1.onchange = function (){

lab1.options[lab1.selectedIndex].value = mat1.value;
lab1.options[lab1.selectedIndex].text= mat1.value;
lab2.options[lab2.selectedIndex].value = mat1.value;
lab2.options[lab2.selectedIndex].text = mat1.value;
  
phase1.options[phase1.selectedIndex].value = 'Fab';
phase1.options[phase1.selectedIndex].text = 'Fab';
phase2.options[phase2.selectedIndex].value = 'Install';
phase2.options[phase2.selectedIndex].text = 'Install';

};

 

Link to comment
Share on other sites

On 7/5/2019 at 5:45 AM, rguardiola1 said:

I'm in the same situation. I need the ability for an If/Then/Else for a calculated field. For example: If a field value if greater than or equal to 0, add these two fields, ELSE don't do a calculation.

Any ideas are welcome.

Thx,

Ruben

I'm working on switching my functions to if/thens as well. Trying to hide elements if the one previous is blank. If I figure it out, I'll update this post.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...