Ver Mensaje Individual
  #5 (permalink)  
Antiguo 08/09/2014, 11:07
julslash
 
Fecha de Ingreso: febrero-2010
Ubicación: valencia
Mensajes: 146
Antigüedad: 14 años, 3 meses
Puntos: 3
Respuesta: Mostrar div previamente seleccionado

alexis88 gracias me diste una idea y use parte de tu codigo


aqui coloco el codigo completo 100 % funcionando


Código HTML:
    <html>
    <head>

	
    <script type="text/javascript">
    function mostrar() {
	var valorinvisible=0;
	valorinvisible=eval(document.getElementById('select').value); // VALOR DEL SELECT
	
	if (valorinvisible==0){
    document.getElementById('e1').style.display ='inherit';
	document.getElementById('e2').style.display ='none';
    document.getElementById('e3').style.display ='none';
	
	}
	
	else if (valorinvisible==1){
	 document.getElementById('e2').style.display ='inherit';
	 document.getElementById('e1').style.display ='none';
     document.getElementById('e3').style.display ='none';
	}
	
	else if (valorinvisible==2){
	 document.getElementById('e3').style.display ='inherit';
	 document.getElementById('e2').style.display ='none';
     document.getElementById('e1').style.display ='none';
	}
	
    }
    </script>
	
	<style type="text/css">
		body {
		color: purple;
		background-color: #d8da3d;
		}
	
	.visible{
        display: inherit;
    }
     
    .invisible{
        display: none;
    }
		
	</style> 
	
	
    </head>
	<body >
	
	<?php
	$valor=3; // Valor que quiere mostrar inicialmente, puede ser sustituido por uno de la base de datos
	
	?>
	
    <form id='alta' name='nalta' method="post" >

	  
     
    <select id="select" onchange='mostrar()'>
    <option value="0">uno</option>
    <option value="1">dos</option>
    <option value="2">tres</option>
    </select>
     <br>
	    <table>

		
		
		
		
		
	 
	  <tr>
     <td>
	 
	 <?php
	 if($valor==1){
	 $clase = 'visible';
	 }
	 else
	 {
	 $clase = 'invisible';
	 }
	 ?>
	 
	 <div id="e1" class = "<?php echo $clase; ?>"> <!---DIV INVISIBLE 1---> 
     
	 
     <font  style="color:#ff3000;">
	   hola 1
	</font>
	
	
    </div> <!---FIN DIV INVISIBLE 1---> 

	
	
    </td>
     </tr>
	 
	 
	 
	 
	 
	 
	 
	 
	   <tr>
     <td>
	 
	 <?php
	 if($valor==2){
	 $clase = 'visible';
	 }
	 else
	 {
	 $clase = 'invisible';
	 }
	 ?>
	 
	 
    <div id="e2" class = "<?php echo $clase; ?>"> <!---DIV INVISIBLE 2---> 
     
    
	   <font  style="color:#ff3000;">
	   hola 2
	</font>
					
	
 
    </div> <!--- FIN DIV INVISIBLE 2---> 
	

	 
	 </td>
     </tr>
	 
	 
	 
	 
	 
	  <tr>
     <td>
	 

	 <?php
	 if($valor==3){
	 $clase = 'visible';
	 }
	 else
	 {
	 $clase = 'invisible';
	 }
	 ?>
	 
	 
    <div id="e3" class = "<?php echo $clase; ?>"> <!---DIV INVISIBLE 3---> 
    
	  <font  style="color:#ff3000;">
	   hola 3
	</font>
					
    </div> <!---FIN DIV INVISIBLE 3---> 
	
   
	 
	 </td>
     </tr>
	  <table>
	
	
    </form>
    </body>
    </html>