I have several text fields, and the value of these fields can be "4", "-2", "10", etc.
I would like to retrieve this value and make the corresponding mathematical operation:
var price = 50;
var value = $ ( "# myTextField").val(); //e.g value = "+50"
var finalprice = price + value
alert(finalprice)
But, of course it doesnt work and only display "50+50". Could you please help me so it can also work if my value was -30 ? Thanks a lot
EDIT: Sorry but you didn't understand me: I need to keep the math operator of my text field (- or +) so I can't convert my string into an Integer.