Código:
Se trata de mostrar un listado de clases al elegir la sesion y al elegir la clase se muestra el costo.<html> <head> <script languaje="JavaScript"> <!-- function setea(formulario){ var costo = formulario['fee']; var select1 = formulario['D1']; select1.selectedIndex = 0; costo.value = ""; } function cambiar(formulario){ var i = 0; var sesiona = formulario['sesion']; var costo = formulario['fee']; var select1 = formulario['D1']; if (sesiona.selectedIndex == 2){ switch(select1.selectedIndex) { case 1: costo.value = '180.00'; break; case 2: costo.value = '189.00'; break; case 3: costo.value = '198.00'; break; case 4: costo.value = '198.00'; break; case 5: costo.value = '225.00'; break; case 6: costo.value = '324.00'; break; }; }; else if (sesiona.selectedIndex == 1){ switch(select1.selectedIndex) { case 1: costo.value = '95.00'; break; case 2: costo.value = '100.00'; break; case 3: costo.value = '105.00'; break; case 4: costo.value = '105.00'; break; case 5: costo.value = '119.00'; break; case 6: costo.value = '171.00'; break; }; }; else if (sesiona.selectedIndex == 3){ switch(select1.selectedIndex) { case 1: costo.value = '20.00'; break; case 2: costo.value = '21.00'; break; case 3: costo.value = '22.00'; break; case 4: costo.value = '22.00'; break; case 5: costo.value = '25.00'; break; case 6: costo.value = '36.00'; break; }; }; } --> </script> <script language="javascript"> function valida_send(){ if (document.formu.D1.selectedIndex==0){ alert("You must select Class Type.") ; document.formu.D1.focus() ; return false; } if (document.formu.D2.value==""){ alert("Complete the field Day and Time.") ; document.formu.D2.focus() ; return false; } if (document.formu.fee.value==""){ alert("You must select Class Type and Session.") ; document.formu.sesion.focus() ; return false; } if (document.formu.fee.value==""){ alert("You must select Class Type and Session.") ; document.formu.sesion.focus() ; return false; } if (document.formu.pfname.value==""){ alert("Complete the field Parent's First Name.") ; document.formu.pfname.focus() ; return false; } if (document.formu.plname.value==""){ alert("Complete the field Parent's Last Name.") ; document.formu.plname.focus() ; return false; } if (document.formu.addr1.value==""){ alert("Complete the field Address Line 1.") ; document.formu.addr1.focus() ; return false; } if (document.formu.city.value==""){ alert("Complete the field City.") ; document.formu.city.focus() ; return false; } if (document.formu.state.selectedIndex==0){ alert("Select a State.") ; document.formu.state.focus() ; return false; } if (document.formu.zip.value==""){ alert("Complete the field Zip.") ; document.formu.zip.focus() ; return false; } if (document.formu.email.value==""){ alert("Complete the Email.") ; document.formu.email.focus() ; return false; } if (document.formu.hphone1.value=="" && document.formu.hphone2.value=="" && document.formu.hphone3.value==""){ alert("Complete the Home Phone Number.") ; document.formu.hphone1.focus() ; return false; } if (document.formu.cfname.value==""){ alert("Complete Child's First Name.") ; document.formu.cfname.focus() ; return false; } if (document.formu.clname.value==""){ alert("Complete Child's Last Name.") ; document.formu.clname.focus() ; return false; } if (document.formu.age_M.value=="" && document.formu.age_Y.value==""){ alert("Complete Child's Current Age.") ; document.formu.age_M.focus() ; return false; } if (document.formu.birthdate.value==""){ alert("Complete Child's Birthdate.") ; document.formu.birthdate.focus() ; return false; } //form sending... alert("Thank you, click to continue."); document.formu.action="reg2.php"; } </script> </head> <body> <form id="formu" name="formu" method="post" onSubmit="return valida_send(this.form);" > <table width="574" border="0" cellpadding="3" cellspacing="0" class="cuadro1"> <tbody> <tr> <td width="212" align="right" bgcolor="#F2F2F2" class="text7A"><div align="right"><strong>* Child's/Children's First Name: </strong></div></td> <td colspan="2" bgcolor="#F2F2F2"><div align="left"> <input name="cfname" size="35" /> </div></td> </tr> <tr> <td align="right" class="text7A"><div align="right"><strong>* Child's/Children's Last Name: </strong></div></td> <td colspan="2"><div align="left"> <input name="clname" size="35" /> </div></td> </tr> <tr> <td rowspan="2" align="right" valign="top" bgcolor="#F2F2F2" class="text7A"><div align="right"><strong>* Child's/Children's Current Age: </strong></div></td> <td height="28" colspan="2" valign="top" bgcolor="#F2F2F2"> <p align="left"> <input size="20" name="age_M" /> <span class="text7A"><strong>month(s</strong></span><strong>) </strong></p></td> </tr> <tr> <td height="30" colspan="2" valign="top" bgcolor="#F2F2F2"><div align="left"> <input size="20" name="age_Y" /> <span class="text7A"><strong>year(s)</strong></span></div></td> </tr> <tr> <td align="right" class="text7A"><div align="right">Child's/Children's Birthdate: </div></td> <td colspan="2"><div align="left"> <input size="30" name="birthdate" /> <span class="text7A">(MM/DD/YYYY)</span></div></td> </tr> <tr> <td align="right" valign="top" bgcolor="#F2F2F2" class="text7A"><div align="right">List any allergies or medical<br /> issues of which the teacher<br /> should be aware: </div></td> <td colspan="2" bgcolor="#F2F2F2"><div align="left"> <textarea name="medissues" rows="3" cols="35"></textarea> </div></td> </tr> <tr> <td bgcolor="#F2F2F2" class="text7A"><div align="right"><strong>*Select Session:</strong></div></td> <td colspan="2" bgcolor="#F2F2F2"><div align="left"> <select name="sesion" onChange="setea(this.form)" id="sesion"> <option value="---">---</option> <option value="5 Weeks">5 Weeks</option> <option value="10 Weeks">10 Weeks</option> <option value="Walk-In">Walk-In</option> </select> </div></td> </tr> <tr> <td class="text7A"><div align="right"><strong>*Select Class Type: </strong></div></td> <td width="222"><div align="left"> <select name="D1" onChange="cambiar(this.form)" id="D1"> <option>---</option> <option>Magical Beginnings</option> <option>Magical Explorations</option> <option>Magical Creations Level 1</option> <option>Magical Creations Level 2</option> <option>Magical Creations Level 3</option> <option>All Ages</option> </select> </div> <div align="left"></div></td> <td width="120"><span class="text7A"><strong>Price: $</strong></span> <input name="fee" id="fee" size="10" readonly="readonly"/></td> </tr> <tr> <td bgcolor="#F2F2F2"><div align="right" class="text7A"><strong>*Select Day and Time: </strong></div></td> <td colspan="2" bgcolor="#F2F2F2"><div align="left"> <input name="D2" id="D2" size="20" /> <span class="text7">(Ex.: Monday, 10:15am)</span></div></td> </tr> </tbody> </table> <div align="center"> <input name="button3" type="submit" id="button3" value="Register Now!" /> </div><br /> </form> </body> </html>
Aparentemente funciona bien en Internet Explorer , pero en Firefox no se muestran los precios.
Se puede apreciar su funcionamiento en esta url
http://74.53.160.2/~edgartta/test/ejemplo.html
Pediría por favor que alguien me eche una mano, gracias.