Foros del Web » Programando para Internet » Javascript »

Ayuda con onchange

Estas en el tema de Ayuda con onchange en el foro de Javascript en Foros del Web. tengo el siguiente codigo Código PHP:   <script type="text/javascript">     $(document).ready(function(){     // Parametros para e combo1    $("#plan").change(function () {            $("#plan option:selected").each(function () {                           //alert($(this).val());                 plan=$(this).val();                 $.post("select_anio.php", { plan:plan }, function(data){                 $("#anio").html(data);                 $("#select_materia").html("");             });                     });    })    $("#anio").change(function () {            $("#anio option:selected").each(function () {             //alert($(this).val());                 anio=$(this).val();                 $.post("select_materia.php", { anio:anio }, function(data){                 $("#select_materia").html(data); ...
  #1 (permalink)  
Antiguo 29/06/2010, 12:00
 
Fecha de Ingreso: febrero-2009
Ubicación: mexico
Mensajes: 148
Antigüedad: 15 años, 2 meses
Puntos: 1
Ayuda con onchange

tengo el siguiente codigo

Código PHP:
  <script type="text/javascript">
    $(document).ready(function(){
    // Parametros para e combo1
   $("#plan").change(function () {
           $("#plan option:selected").each(function () {              
            //alert($(this).val());
                plan=$(this).val();
                $.post("select_anio.php", { plan:plan }, function(data){
                $("#anio").html(data);
                $("#select_materia").html("");
            });            
        });
   })
   $("#anio").change(function () {
           $("#anio option:selected").each(function () {
            //alert($(this).val());
                anio=$(this).val();
                $.post("select_materia.php", { anio:anio }, function(data){
                $("#select_materia").html(data);
            });            
        });
   })
   });
    </script>  

<td>PLAN DE ESTUDIO</td>
<td>
<select name="plan" id="plan" class="validate[required] text-input" style="width: auto;">
<option value="">Selecciona</option>
<?php
$plan_estudio
=new PlanEstudioSecundaria();
$rs=$plan_estudio->consultar("ORDER BY anio");
while(
$row=$rs->fetch_assoc())
{
?>
<option value="<?php echo $row["id_plan_estudio_secundaria"];?>"><?php echo $row["anio"];?></option>
<?php
}
?>
</select>
</td>
<td>AÑO</td>
<td><div id="anio"></div></td>//Aqui aparece lo que el select anterior me carga
<td><div id="select_materia"></div></td>//Aqui deberia de aparecer depenediendo lo que selecciono del segundo select select el cual se genero con el primero
select_anio.php

Código PHP:
<?php
include("../../../clases/Cargar_clases.php");

$plan=$_POST["plan"];

$materia_secundaria=new MateriaSecundaria();
$rs=$materia_secundaria->consultar("AND materias_secundaria.id_plan_estudio_secundaria='$plan' GROUP BY materias_secundaria.anio");
?>
<td>
<select name="anio" id="anio" class="validate[required] text-input" style="width: auto;">
<option value="">Selecciona</option>
<?php
while($row=$rs->fetch_assoc())
{
?>
<option value="<?php echo $row["anio"];?>"><?php echo $row["anio"];?></option>
<?php
}
?>
</select>
</td>
select_materia.php
Código PHP:
<?php
include("../../../clases/Cargar_clases.php");
$anio=$_POST["anio"];
?>
<table border="1">
<tr class="titulos">
<td>MATERIAS</td>
</tr>
<?php
$materias
=new MateriaSecundaria();
$rs=$materias->consultar("AND materias_secundaria.anio='$anio'");
while(
$row=$rs->fetch_assoc())
{
$id_materia_secundaria=$row["id_materia_secundaria"];
$materia=$row["nombre"];
?>
<tr class="contenido">
<td>
<input type="hidden" name="id_materia_secundaria[]" value="<?php echo $id_materia_secundaria;?>" />
<?php echo $materia;?>
</td>
</tr>
<?
}
?>
<tr class="titulos">
<td><input type="submit" name="Guardar" value="Guardar" class="btn btnguardar" onclick="return confirm('¿PRESIONE CANCELAR SI DESEA REALIZAR ALGUN CAMBIO?')" /></td>
</tr>
</table>
el problema esta en cuando escojo datos del segundo select la segunda capa no me muestra nada, esto solo pasa en ie y en firefox me jala bien, alguna ayuda por favor
  #2 (permalink)  
Antiguo 29/06/2010, 12:12
Avatar de masterojitos  
Fecha de Ingreso: julio-2008
Ubicación: Lima Callao Chucuito
Mensajes: 1.931
Antigüedad: 15 años, 9 meses
Puntos: 105
Respuesta: Ayuda con onchange

en vez de hacer
$("#anio").change(function () {
intenta creando una funcion y llamandola en el evento onchange
<select name="anio" id="anio" class="validate[required] text-input" style="width: auto;" onchange="changeAnio()">

Suerte.
__________________
Atte. MasterOjitos :ojotes:
Todo sobre Programación Web
Las ultimas tendencias en Efectos y Recursos Web: MasterOjitos Blog
  #3 (permalink)  
Antiguo 29/06/2010, 20:28
 
Fecha de Ingreso: febrero-2009
Ubicación: mexico
Mensajes: 148
Antigüedad: 15 años, 2 meses
Puntos: 1
Respuesta: Ayuda con onchange

Cita:
Iniciado por masterojitos Ver Mensaje
en vez de hacer
$("#anio").change(function () {
intenta creando una funcion y llamandola en el evento onchange
<select name="anio" id="anio" class="validate[required] text-input" style="width: auto;" onchange="changeAnio()">

Suerte.
pero como hago la funcion, nomas no me da la cabeza para hacerla, ayuda por favor, necesito que esto funcione bien con ie 6,7 y 8 de perdida con ie 7 y 8

Etiquetas: onchange
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 20:27.