[ad_1]
Hello friend,
i try to combine an if statement with the case statement.
fieldname2 = amount (number)
fieldname3 = source unit (dropdown)
fieldname5 = target unit (dropdown)
fieldname6-10 = other target units for category like speed, volume, distance, etc., all dropdowns
What I try to achieve in words:
Check fieldname3 for the unit (text string)
Then, if source unit = m, check the target unit in fieldname5
return results for all cases
then if source unit = cm, check target unit in fieldname5
return result for all cases
This code is only if source unit is “m”.
I gets no result.
Maybe, if you can make it work, you can add a second switch block if fieldname3 = cm or something?
`(function(){
if(fieldname3 == ‘m’,
switch(fieldname5)
{
case ‘mm’: return PREC(fieldname2/1000,2);
case ‘cm’: return PREC(fieldname2/100,2);
case ‘dm’: return PREC(fieldname2/10,2);
case ‘m’: return PREC(fieldname2*1,2);
case ‘km’: return PREC(fieldname2*1000,2);
}
)
})()’
Thank you so much
