I’m trying to build a form that calculates ad prices. The problem is, each section has a different base value. So I’m trying to get jQuery to evaluate the variable, but it’s only evaluating the text. Eval() works here, because it returns the variable and not the text.
var onlineAdCalc =eval($('#onlineAdSection').val()+$('#onlineAdSize').val());
$('#onlineAdSection') and $('#onlineAdSize') are both select boxes.
For example,
var homebox = 38.4;
$('#onlineAdSection').val() = home;
$('#onlineAdSize').val() = box;
with eval
onlineAdCalc = 38.4
without eval
onlineAdCalc = homebox
Try using a hash to store your output: