Jump to content


Photo

rescatar value de un combobox


  • Please log in to reply
4 replies to this topic

#1 tquezada

tquezada

    Newbie

  • Miembros
  • Pip
  • 8 posts

Posted 24 April 2013 - 12:05 PM

hola a todos tengo este script
[html5]
<?
session_start();
set_time_limit(0);
include("../inc/funciones.php");
include("../inc/oConn.php");
include("../inc/DesaWebPrueba.php");
?>
<html>
<head>
<title>Problema</title>
<script language="javascript">function crearText()
{
  var actuales = document.getElementById('seccion');
  var cant=actuales.childNodes.length;
  for(f=0;f<cant;f  )
  {
    actuales.removeChild(actuales.childNodes[0]);
  }
  var se = document.getElementById('seleccion');
  var cantidad=0;
  for(f=0;f<se.value;f  )
  {
    cantidad  ;
    var nuevohijo = document.createElement('input');
    nuevohijo.type = 'text';
    nuevohijo.name = 'deporte[]';
    nuevohijo.id = 'nombre'  cantidad;
    document.getElementById('seccion').appendChild(nuevohijo);
    document.getElementById('seccion').appendChild(document.createElement('br'));
  }
}
</script>

</head>
<body>

<tr>
    <td valign="top">Tipo de Deporte:<br /><br /><br />Integrantes:</td>
   
    <td valign="top">

    <select onChange="crearText()" id="seleccion">
    <option value="0">Seleccione</option>
  <?
    $strSQL = "select          id_deporte,
                      INITCAP(deporte),
                      integrantes
                      from RESERVA_DEPORTE order by id_deporte asc";   
    $rsConn = $dbDesaP->Execute($strSQL) or die("Error");
           
       
    while(!$rsConn->EOF){
    ?>
    <option value="<?php echo $rsConn->fields[2];?>"><?php echo $rsConn->fields[1];?></option>
    <?
    $rsConn->MoveNext();
    }
    ?>
    </select>
    <br>
<div id="seccion">
</div>
<br>
   
    </td>
  </tr>
</form>
</body>
</html>
[/html5]


necesito rescatar el id del deporte seleccionado, pero en el value tengo los integrantes para generar los textbox, como puedo hacer para recoger la id en una variable para guardarla en una tabla?

Saludos.-
  • 0

#2 poliburro

poliburro

    Advanced Member

  • Administrador
  • 4945 posts
  • LocationMéxico

Posted 24 April 2013 - 01:00 PM

a tu código le falta el form de apertura que indica a que script se enviará el contenido del formulario.

y agregar un botón dentro del bloque form de la forma



  <input type="submit">

  • 0

#3 tquezada

tquezada

    Newbie

  • Miembros
  • Pip
  • 8 posts

Posted 24 April 2013 - 01:08 PM

gracias por responder

si tienes razon copie mal el codigo

pero mi duda es como poder poner dos valores en el value, ocupar solo uno en la funcion javascript y luego poder separarlas en varibles distintas
  • 0

#4 poliburro

poliburro

    Advanced Member

  • Administrador
  • 4945 posts
  • LocationMéxico

Posted 24 April 2013 - 01:13 PM

allí lo que puedes hacer es concatenar ambos valores separados por un caracter especial y cuando leas el valor en javascript separarlo.

algo como

value="valor1@valor2"


  • 0

#5 luisgutierrezb

luisgutierrezb

    Advanced Member

  • Miembros
  • PipPipPip
  • 92 posts
  • LocationMéxico

Posted 24 April 2013 - 01:50 PM

Otra opcion, tambien puedes crear un campo de la forma de tipo "hidden" para obtener uno de los valores y el otro en el value...
  • 0




IP.Board spam blocked by CleanTalk.