Ver Mensaje Individual
  #2 (permalink)  
Antiguo 06/04/2011, 14:49
Avatar de laratik
laratik
 
Fecha de Ingreso: mayo-2010
Ubicación: Cali
Mensajes: 317
Antigüedad: 13 años, 11 meses
Puntos: 63
Respuesta: problemas con un formulario y (getElementById)

Código HTML:
<html>
<head>
<script type="text/javascript">
function setButton(el_id){
document.getElementById("cero_tr").style.display ="none";
document.getElementById("uno_tr").style.display ="none";

document.getElementById("dos_tr").style.display ="none";
document.getElementById("tres_tr").style.display ="none";
document.getElementById("cuatro_tr").style.display ="none";
document.getElementById(el_id).style.display ="block";
}
</script>

</head>
<body>
<form name="form1" method="post" action="ejemplo.php">
<input type="radio" name="opcion" value="cero" onClick='setButton("cero_tr");'>cero<br/>
<input type="radio" name="opcion" value="uno" onClick='setButton("uno_tr");'>uno<br/>
<input type="radio" name="opcion" value="dos" onClick='setButton("dos_tr");'>dos<br/>
<input type="radio" name="opcion" value="tres" onClick='setButton("tres_tr");'>tres<br/>
<input type="radio" name="opcion" value="cuatro" onClick='setButton("cuatro_tr");'>cuatro<br/>
<input type="submit"value="ok" />
</form>
<table>
<tr id="cero_tr" bgcolor="#000000" style=" display:none; width:100px; height:100px;"><td>uno</td></tr>
<tr id="uno_tr" bgcolor="#333333" style=" display:none; width:100px; height:100px;"><td>dos</td></tr>
<tr id="dos_tr" bgcolor="#666666" style=" display:none; width:100px; height:100px;"><td>tres</td></tr>
<tr id="tres_tr" bgcolor="#222222" style=" display:none; width:100px; height:100px;"><td></td><td>cuatro</td></tr>
<tr id="cuatro_tr" bgcolor="#444444" style=" display:none; width:100px; height:100px;"><td>cinco</td></tr>
</table>
</body>
</html> 
ERRORES
1. Falta la etiqueta table
2. los valores enviados no estaban entre comillas
3. tres estaba fuera de las etiquetas <td></td>
__________________
Programar apasiona y lo que apasiona es un arte, por lo tanto programar es un arte.

Quiero karma para en mi próxima vida ser un billonario bien dotado con alas.