Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/10/2012, 02:56
neveuster
 
Fecha de Ingreso: febrero-2012
Mensajes: 163
Antigüedad: 12 años, 2 meses
Puntos: 0
Al eliminar restar valor de fila a caja de texto

Estimados... tengo el siguiente código

Código:
<table>
    <tr>
        <td><input type="button" onclick="remove(this)" value="Eliminar" /></td><td>dato</td><td><input type="text" name="valor" id="valor" value="32"></td>
    </tr>
    <tr>
        <td><input type="button" onclick="remove(this)" value="Eliminar" /></td><td>dato</td><td><input type="text" name="valor" id="valor" value="40"></td>
    </tr>
    <tr>
        <td><input type="button" onclick="remove(this)" value="Eliminar" /></td><td>dato</td><td><input type="text" name="valor" id="valor" value="18"></td>
    </tr>
    <tr>
        <td>TOTAL:<input type="text" name="total" id="total" value="300"></td>
    </tr>
</table>
Código Javascript:
Ver original
  1. function remove(t)
  2.     {
  3.         var td = t.parentNode;
  4.         var tr = td.parentNode;
  5.         var table = tr.parentNode;
  6.         table.removeChild(tr);
  7.     }


como hago para que al eliminar una fila me reste su valor al campo de texto "total" que se encuentra abajo??

he intentado poner algo como esto en la función pero no me resulta...
Código Javascript:
Ver original
  1. var tot = $("#valor").val();
  2.         var p = document.getElementById("total");
  3.         var dinero=parseInt(p.value);
  4.         p.value=dinero-tot

bueno, les ruego me ayuden ya que no he podido hacerlo.. saludos y gracias.