I need to perform calculation on dynamic string.
I will get an equation from db named rule through ajax. the rule may contain equation with operators like +,-,*,/,%.
how to perform this calculation?
for (var i = 0; i < rules.length; i++) {
var rule = rules[i].rule; // may contain $structurename1$*$structurename2$/$structurename3$ like this
$('form :input[type="text"]').each(function(index,value){
rule = rule.replace('$'+$(this).attr('structurename')+'$',$(this).val());
});
}
$('#result').val(rule);