Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/06/2011, 15:27
bon3
 
Fecha de Ingreso: mayo-2011
Mensajes: 55
Antigüedad: 13 años
Puntos: 1
Pregunta Como puedo hacer esto?

Tengo este codigo que pasa valores de un select multiple a otro quisiera saber como poder hacerle para que los datos del primer select multiple donde estan los numeros como le hago para que esos datos se pongan automaticamente desde una base de datos?

Código PHP:
<html>
<head>
<script type="text/javascript">
function insertar() {
    obj=document.getElementById('sel1');
    if (obj.selectedIndex==-1) return;
    valor=obj.value;
    txt=obj.options[obj.selectedIndex].text;
    obj.options[obj.selectedIndex]=null;
    obj2=document.getElementById('sel2');
    opc = new Option(txt,valor);
    eval(obj2.options[obj2.options.length]=opc);
}
function eliminar(){
    obj2=document.getElementById('sel2');
    if (obj2.selectedIndex==-1) return;
    valor=obj2.value;
    txt=obj2.options[obj2.selectedIndex].text;
    obj2.options[obj2.selectedIndex]=null;
    obj1=document.getElementById('sel1');
    opc = new Option(txt,valor);
    eval(obj1.options[obj1.options.length]=opc);
}
function vaciar() {
  obj2 = document.getElementById('sel2');
  num = obj2.options.length;
  for (i=num-1; i>=0; i--) {
    txt=obj2.options[i].text;
    valor=obj2.options[i].value;
    obj2.options[i]=null;
    obj=document.getElementById('sel1');
    opc = new Option(txt,valor);
    eval(obj.options[obj.options.length]=opc);
  }
}
</script>
</head>
<body>
<?php
        $myTextArea
=$_POST['myTextArea'];
        echo 
"<hr noshade>";
        echo 
$myTextArea;
        
$ok=1;
?>
        <hr noshade><br><br><form action="go.php" method="post">
            <center>Tema del mensaje (subject):
            <input type="text" name="subjet" size="25"><br><br><br>
            <input type="hidden" name="myTextArea" value="<?echo $myTextArea?>">

    <table border="1">
      <tr>
        <td rowspan="3"><select id="sel1" size="10" style="width:150;" multiple>
           <option value="0">0</option>
<option value="1">1</option>
<option value="2">3</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>

          </select></td>
        <td><div align="center">
            <input name="button" type="button" onClick="insertar()" value="Incluir >">
          </div></td>
        <td rowspan="3"><select name="select" size="10" multiple id="sel2" style="width:150;">
          </select></td>
      </tr>
      <tr>
        <td><div align="center">
            <input name="button" type="button" onClick="eliminar()" value="< Sacar">
          </div></td>
      </tr>
      <tr>
        <td><div align="center"><input name="button" type="button" onClick="vaciar()" value=" << Vaciar"></div></td>
      </tr>
      <tr>
        <td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
        <td><input name="submit" type="submit" value="Confirmar y enviar"></td>
        <td>&nbsp;</td>
      </tr>
    </table>

</center></form>
</body>
</html>