Ver Mensaje Individual
  #9 (permalink)  
Antiguo 12/09/2008, 15:03
Avatar de pepeverastegui
pepeverastegui
 
Fecha de Ingreso: septiembre-2008
Ubicación: Pedernales, Michoacan
Mensajes: 82
Antigüedad: 15 años, 7 meses
Puntos: 2
Respuesta: Como cargar un combo a partir de una seleccion de checkbox

Código PHP:
<html>
<head>
<title>Prueba Combo</title>
<script type="text/javascript">
function cambio(chk)
{
   if(chk.checked == true)
   {   
      var j = document.f1.op.options.length;
      document.f1.op.options[j] = new Option(chk.value);
   }
   else
   {
      var i = 0;
      for(i=0; i<document.f1.op.options.length; i++)
      {
         if(document.f1.op.options[i].value == chk.value)
         {
            var sel = document.f1.op;
            sel.options[i] = null;
         }
      }
   }
}
</script>
</head>
<body>
<form name=f1>
<?php
$db 
mysql_connect("localhost""root""verastegui");
mysql_select_db("prueba");
$res mysql_query("select * from prueba1");
for(
$i=0$i<mysql_num_rows($res); $i++)
{
   
mysql_data_seek($res$i);
   
$row mysql_fetch_object($res);
   print 
"<input type='checkbox' value='$row->c1' name=chk onclick='return cambio(this)'>$row->c1<br>";
}
?>
<select name=op>
<option>-----</option>
</select>
<?php
mysql_close
($db);
?>
</form>
</body>
</html>
ps alo que te entendi haber si es lo que pides y te sirve el codigo, cualquier cosa
[email protected] mi correo