Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/04/2012, 10:04
Avatar de REVIDEUX
REVIDEUX
 
Fecha de Ingreso: septiembre-2011
Ubicación: Lima, Peru, Peru
Mensajes: 23
Antigüedad: 12 años, 7 meses
Puntos: 0
Respuesta: Sumar y multiplicar en jquery con .val()

Hola:

Estoy totalmente de acuerdo con Dafonz, ahora que si bien quieres llenar otro textbox seria asi:
Código Javascript:
Ver original
  1. $(document).ready(function () {
  2.         $("#Agregar").click(function (e) {
  3.             var mat = $("#Material").val();
  4.             var price = $("#Price").val();
  5.             var resultado = parseFloat(mat) + parseFloat(price);
  6.             alert(resultado);
  7.             var resultado2 = mat * price;
  8.             alert(resultado2);
  9.             $("#Resultado").val(resultado);
  10.         });
  11.     });

desde un html:
Código HTML:
Ver original
  1. Material: <input type="text" value="" id="Material" name="Material" />
  2. <br />
  3. Price: <input type="text" value="" id="Price" name="Price" />
  4. <br />
  5. Resultado: <input type="text" value="" id="Resultado" name="Resultado" />
  6. <br />
  7. <input type="submit" value="Agregar" id="Agregar"/>


Si hay algun otro inconveniente te agradecere en comunicarlo oks