Ver Mensaje Individual
  #2 (permalink)  
Antiguo 25/04/2010, 14:40
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 3 meses
Puntos: 126
Respuesta: Suma de valores con boton radio

Hola

Con esa actitud de "ha ver si me podria dan un codigo" no lograrás mucho. Será mejor que empieces a trabajar un poco y así los demás intentaremos ayudarte en todo lo que nos sea posible. Espero que en futuras consultas no pidas que se te de, sino que se te colabore con un
código

Código Javascript:
Ver original
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. var elemArr = new Array ( new Array ('100'), new Array ('1'));
  5. function valores() {
  6. var imp_total = document.getElementById("total");
  7. var elemInput = document.getElementById('formulario').getElementsByTagName('label');
  8.  
  9.     for(var i = 0; i < elemInput.length; i++){
  10. var elem = elemInput[i].getElementsByTagName('input');
  11.         for(var j = 0; j < elem.length; j++){
  12.             elem[j].onclick = function() {
  13.                 elemArr[this.name].unshift(this.value);
  14.                 //alert ("El arreglo es: " + elemArr[0][0] + " - " + elemArr[1][0]);
  15.                 imp_total.value = parseInt(elemArr[0][0] * elemArr[1][0]);
  16.             }
  17.         }
  18.     }
  19.  
  20. }
  21.  
  22. window.onload = function() {valores()};
  23. </script>
  24. </head>
  25. <body>
  26. <form id="formulario">
  27. <label for="nroPag">Nº P&aacute;ginas
  28. <input id="nroPag[]" type="radio" name="0" value="100" class="radio" checked="checked" />
  29. <input id="nroPag[]" type="radio" name="0" value="200" class="radio" />
  30. <input id="nroPag[]" type="radio" name="0" value="300" class="radio" />
  31. </label>
  32. <label for="nroDia">Di&aacute;s
  33. <input id="nroDia[]" type="radio" name="1" value="1"  class="radio" checked="checked" />
  34. <input id="nroDia[]" type="radio" name="1" value="2"  class="radio" />
  35. </label>
  36. <p name="subtotalResumen">TOTAL: <input name="total" id="total1" type="text" value="0" /></p>
  37. </form>
  38. </body>
  39. </html>

Suerte
__________________
Los formularios se envían/validan con un botón Submit
<input type="submit" value="Enviar" style="background-color:#0B5795; font:bold 10px verdana; color:#FFF;" />