Jquery Input

hola amigos… necesito ayuda… no tengo ni idea de como codificar mi idea…

a ver, tengo un select q me selecciona un tipo de asistente, el caso es interno o externo.

yo necesito q si me selecciona interno me muestre los datos (nombre, apellido, cedula)que estan guardados en un modelo que se llama personal.

si selecciona externo debe mostrarme los mismos datos pero de un modelo q se llama asistentes.

lo q pasa es q personal, corresponde a la base de datos de la red interna de la compañia, y asistente es algo q yo estoy creando para mi bd.

lo q necesito es q al seleccionar interno se oculte el otro campo y viceversa.

Buenas.

Supongo q buscas algo como esto:




<div id='divInterno' style='display: none;'>

Aquí los datos de interno

</div>


<div id='divExterno' style='display: none;'>

Aquí los datos de externo

</div>


<script>

    $('#nombreListaDesplegable').change(

        function()

        {

            var opcionSeleccionada = $(this);                                   

            var valorSeleccionado = opcionSeleccionada.val();                         

               

            if(valorSeleccionado == 'interno')      

           {                                           

                $('#divInterno').show('slow');

                $('#divExterno').hide('slow');

           }

            else              {                                                  

                $('#divInterno').hide('slow');

                $('#divExterno').show('slow');

           }

        }

    );      

</script>



Tú adáptalo a tu vista y listo.

Un saludo.

hola… mira lo que hice? pero ahora no me agurda los datos:

<html>

<head>

<script>

function pagoOnChange(sel) {

  if (sel.value==&quot;Interno&quot;){


       divC = document.getElementById(&quot;Personal&quot;);


       divC.style.display = &quot;&quot;;





       divT = document.getElementById(&quot;MinutaAsis&quot;);


       divT.style.display = &quot;none&quot;;





  }else{





       divC = document.getElementById(&quot;Personal&quot;);


       divC.style.display=&quot;none&quot;;





       divT = document.getElementById(&quot;MinutaAsis&quot;);


       divT.style.display = &quot;&quot;;


  }

}

</script>

</head>

<body>

<div>

  &lt;div&gt;


       &lt;SELECT NAME=&quot;tipo&quot; onChange=&quot;pagoOnChange(this)&quot;&gt;


          &lt;OPTION VALUE=&quot;Interno&quot;&gt;Asistente Interno&lt;/OPTION&gt;


          &lt;OPTION VALUE=&quot;Externo&quot;&gt;Asistente Externo&lt;/OPTION&gt; 


       &lt;/SELECT&gt;


  &lt;/div&gt;


  &lt;div id=&quot;Personal&quot; style=&quot;display:none;&quot;&gt;


  &lt;?php echo &#036;form-&gt;labelEx(&#036;tipo,'Nombre'); ?&gt;


  &lt;?php echo &#036;form-&gt;dropDownList(&#036;tipo,'cedula', CHtml::listData(Personal::model()-&gt;findAll(), 'cedula', 'nombre')); ?&gt;


  &lt;?php echo &#036;form-&gt;error(&#036;tipo,'cedula'); ?&gt;


	


  &lt;/div&gt;


  &lt;div id=&quot;MinutaAsis&quot; style=&quot;display:;&quot;&gt;


       &lt;br&gt;


&lt;?php echo &#036;form-&gt;labelEx(&#036;tipo,'Nombre'); ?&gt;


&lt;?php echo &#036;form-&gt;dropDownList(&#036;tipo,'cedula', CHtml::listData(Asistente::model()-&gt;findAll(), 'cedula', 'nombre')); ?&gt;


&lt;?php echo &#036;form-&gt;error(&#036;tipo,'cedula'); ?&gt;


	       &lt;br&gt;


  &lt;/div&gt;

</div>

</body>

</html>

si lo hago como tu dices no me funciona… puedes chequearlo?

</div>

&lt;div class=&quot;row&quot;&gt;


&lt;?php echo &#036;form-&gt;labelEx(&#036;tipo,'Tipo'); ?&gt;


&lt;?php &#036;options = array('Interno'=&gt;'Interno','Externo'=&gt;'Externo');?&gt;


&lt;?php echo &#036;form-&gt;dropDownList(&#036;tipo,'tipo', &#036;options,array('empty' =&gt; 'Seleccione ...',)); ?&gt;


&lt;?php echo &#036;form-&gt;error(&#036;tipo,'tipo'); ?&gt;


&lt;/div&gt;











&#60;script&gt;


&#036;('#options').change(


    function()


    {


        var opcionSeleccionada = &#036;(this);                                   


        var valorSeleccionado = opcionSeleccionada.val();                         


           


        if(valorSeleccionado == 'Interno')      


       {                                           


            &#036;('#divInterno').show('slow');


            &#036;('#divExterno').hide('slow');


       }


        else              {                                                  


            &#036;('#divInterno').hide('slow');


            &#036;('#divExterno').show('slow');


       }


    }


);      

</script>

<div id=‘divInterno’ style=‘display: none;’>

<?php echo $form->dropDownList($tipo,‘cedula’, CHtml::listData(Personal::model()->findAll(), ‘cedula’, ‘nombre’)); ?>

<?php echo $form->error($tipo,‘cedula’); ?>

</div>

<div id=‘divExterno’ style=‘display: none;’>

<?php echo $form->dropDownList($tipo,‘cedula’, CHtml::listData(Asistente::model()->findAll(), ‘cedula’, ‘nombre’)); ?>

<?php echo $form->error($tipo,‘cedula’); ?>

</div>

Y cuál es la dropDownList con nombre "options" ?

Te falta nombrar la lista de opciones:




<div class="row">

<?php

     echo $form->labelEx($tipo,'Tipo');

     $options = array('Interno'=>'Interno','Externo'=>'Externo');

     echo $form->dropDownList($tipo,'tipo', $options,

          array('empty' => 'Seleccione ...', 'id'=>'options'));

     echo $form->error($tipo,'tipo'); 

?>

</div>



Un saludo.