Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/06/2009, 10:18
tomuer01
 
Fecha de Ingreso: enero-2009
Mensajes: 106
Antigüedad: 15 años, 3 meses
Puntos: 0
Pregunta Ayuda con Exportar datos de un Select Multiple

Hola a todos...Estoy haciendo un sistema en el cual hay una opcion para exportar los datos a excel, lo que hago es un select multiple que lleno con una consulta a my BD MySQL, selecciono los datos que me interesan y los paso a otro select multiple, hasta aqui todo bien, el problema es que necesito exportar los datos seleccionados...¿Alguien conoce algun metodo para hacer esto?

Aqui esta el codigo:

Funcion para pasar de un select multiple a otro.

Código:
<script type="text/javascript"> 
var __RE_STA = /^([+-]*)?(.*)$/;
function mvopt(s,d){
  if (s.selectedIndex < 0)
	  return (false);
  var o = s.options, O;
  for (var i = 0; o[i]; i++)
    if (o[i].selected == true) {
      O = document.createElement("OPTION");
      O.text = O.value = o[i].value.replace(__RE_STA, '$2');
      d.options.add(O);
      s.remove(i--);
		}
}
</script>
Codigo HTML y PHP donde realizo el proceso de seleccion, queda lo mas importante...la exportacion.

Código:
<fieldset>
            <legend class="titulos_campo_azul" align="center">Seleccione Medidores A Exportar</legend>
              <table width="800" border="0">
              <br>
                     <td width="375" rowspan="2">
                      <select name='med1' size='15' multiple='mult1' id='med1' align='center' class="titulos_campo_azul" style="width:350px">
                <?php
				if($marca=='4')
				{
    				 $sql = mysql_query("SELECT * FROM medidores WHERE id_marca='$marca' GROUP BY descripcion ");
					 while ($row = mysql_fetch_row($sql)) {
   					 for ($i=2;$i<=2;$i++) {
     				 echo "
					 <option value='$row[$i]'/> ".$row[$i]."<br>";
  					 }
					 }
				}
				if($marca=='5')
				{
    				 $sql = mysql_query("SELECT * FROM medidores WHERE id_marca='$marca' and descripcion LIKE '%TOT%' GROUP BY descripcion ");
					 while ($row = mysql_fetch_row($sql)) {
   					 for ($i=2;$i<=2;$i++) {
     				 echo "
					 <option value='$row[$i]'/> ".$row[$i]."<br>";
  					 }
					 }
				}
					 ?>
                     </select>
                     <td align="center" valign="baseline" id="add">
                     <img src="../Images/botones/Arrow_add.png" alt="Agregar" name="add" align="baseline" id="add" onClick="mvopt(document.getElementById('med1'),document.getElementById('med2'))" onMouseOver="this.style.cursor='hand'">
                     </td>
                     <td width="375" rowspan="2">
                     <select multiple='mult2' name="med2" size="15" id="med2" align='center' class="titulos_campo_azul" style="width:350px">
                     </select>
                     </td>
                     <tr>
                       <td align="center" valign="top">
                       <img src="../Images/botones/Arrow_del.png" alt="Quitar" name="del" align="top" id="del" onClick="mvopt(document.getElementById('med2'),document.getElementById('med1'))" onMouseOver="this.style.cursor='hand'"></td>                      
                     </table>
                     </fieldset>
                     
                     <a href="select_date_exp.php"><img src="../Images/botones/Database_4.gif" alt="Exportar Medidores" width="100" height="255"></a>
Gracias por su ayuda...