Ver Mensaje Individual
  #2 (permalink)  
Antiguo 26/03/2010, 16:36
Avatar de Adler
Adler
Colaborador
 
Fecha de Ingreso: diciembre-2006
Mensajes: 4.671
Antigüedad: 17 años, 4 meses
Puntos: 126
Respuesta: radiobotones dependientes para mostrar valor en un input text

Hola

Prueba así

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