I have a simple problem to solve, I know how to do it in PHP but have no ideia how to do it in javascript.
I gave a dinamic form, with N lines.
// HTML
<form>
$total = 0;
for($x...){
?><input type="text" name="field<?PHP echo $x; ?>" onChange="f5(this.form,<?PHP echo $total; ?>)" />
$total++;
}
</form>
//Js
function f5(formulario,total){
math = 0;
for(numero=0; numero<=total; numero++){
var foo+eval(numero) = formulario.quantidade+eval(numero).value
math = math + foo+eval(numero);
}
}
In Js I need to get all values of the form and do some maths and send it back to the html.
Anyone have an example of how do that? I am trying to use eval() funcion with no sucess.
Regards,
Thanks,
You can use the bracket operator to access a dynamic property
Here’s a live example http://jsfiddle.net/WFdZJ/