Anyone knows why the calculation field returns an error when converting a string into an integer?
var $prix = Max of Prix de vente; //Value is 2000.00
var $titre = All of Nom du produit;
var $nbr_heure = $titre[0].substring(0, 3).trim(); //Value is "25"
parseInt($nbr_heure)
parseInt($prix)
returns 2000
I have tried parseFloat()
and Number()
. It seems like as soon as it tried to convert a string, it doesn't process.
My static workaround
var $prix = Max of Prix de vente;
var $titre = All of Nom du produit;
var $nbr_heure = $titre[0].substring(0, 3).trim();
var $taux_horaire = 0;
//Conversion stupide manuelle
if($nbr_heure == "25")
$taux_horaire = $prix / 25;
else if($nbr_heure == "50")
$taux_horaire = $prix / 50;
else if($nbr_heure == "100")
$taux_horaire = $prix / 100;
else
$taux_horaire = 89;
$taux_horaire;
More info, if you do this:
$prix + parseInt($nbr_heure); //Same error
and
$prix + $nbr_heure; //Gives 200025 (String concatenation)
Thank you for any feedback!