vendredi 15 juillet 2016

Using IF Else with IF Statements

I'm using JS to calculate some inputs on a form. I'm using a few IF statements based on the type of user logged in and also the value they have inputted into a field.

To summarise, the formula is structured as follows:

IF logged-in user is administrator or contributor, run formula 1. Otherwise, if user is subscriber run formula 2.

I wish to add a third rule now, such as, if logged in user is 'customer', run rate 3.

The challenge I'm facing is knowing which IF statement to accommodate the new variation and where it should be placed, I assume, after the first formula?

Here's what I have so far:

(function(){
 if(fieldname152=='administrator','contributor') return IF((fieldname130<=1000),(fieldname130)*50.40/1000,IF(fieldname130<=10000,(fieldname130)*50.40/1000,IF(fieldname130<=50000,(fieldname130)*50.90/1000,IF(fieldname130<=500000,(fieldname130)*50.45/1000))));
 else if(fieldname152=='subscriber') return IF((fieldname130<=1000),(fieldname130)*49.40/1000,IF(fieldname130<=10000,(fieldname130)*49.40/1000,IF(fieldname130<=50000,(fieldname130)*48.90/1000,IF(fieldname130<=500000,(fieldname130)*48.45/1000))));
 })()

Any help would be greatly appreciated.

S

Aucun commentaire:

Enregistrer un commentaire