Hola
Pongamos por caso que tu HTML es algo como esto
Código HTML:
Ver original<input type="text" id="camp_1_precio" name="precio" value="100" /> <input type="text" id="camp_1" name="cantidad" value="" onkeypress="funcion(this.id, this.value);" />
<input type="text" id="camp_2_precio" name="precio" value="100" /> <input type="text" id="camp_2" name="cantidad" value="" onkeypress="funcion(this.id, this.value);" />
El javascript
Código Javascript
:
Ver originalfunction funcion(id, val) {
document.getElementById(id+'_total').innerHTML = document.getElementById(id+'_precio').value * val;
}
Suerte