Foros del Web » Programando para Internet » Javascript »

Select ONCHANGE??

Estas en el tema de Select ONCHANGE?? en el foro de Javascript en Foros del Web. Hola a todos tego una incognita en un select que esta tomando los valores de un tabla como haria para obtener el valor que cambia ...
  #1 (permalink)  
Antiguo 13/12/2007, 08:19
Avatar de agressor  
Fecha de Ingreso: noviembre-2007
Ubicación: Knocking the Death Door..
Mensajes: 368
Antigüedad: 16 años, 5 meses
Puntos: 3
Pregunta Select ONCHANGE??

Hola a todos tego una incognita en un select que esta tomando los valores de un tabla como haria para obtener el valor que cambia en ese select?? no se si me entienden cuando seleccione una de las opciones como haria para saber que opcion selecciono..??

adjunto el codigo..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Search</title>
<link href="file:///C|/AppServ/www/css/stylesheet.css" rel="stylesheet" type="text/css" />

<link href="../../css/stylesheet.css" rel="stylesheet" type="text/css" />
<script>
function ocultarFila(num,ver) {
dis= ver ? '' : 'none';
tab=document.getElementById('tabla');
tab.getElementsByTagName('tr')[num].style.display=dis;
}
</script>
<style type="text/css">
<!--
.style11 {font-size: 14px}
.style12 {color: #FFFFFF}
-->
</style>
</head>
<body onload="ocultarFila(2,false);ocultarFila(3,false); ocultarFila(4,false);ocultarFila(5,false);ocultarF ila(6,false);">
<div class="blur">
<div class="shadow">
<div class="content">
<form id="searchFrm" name="searchFrm" method="GET" action="results.php">
<table id="tabla" width="385" border="0" align="rigth">
<tr>
<td colspan="2"><span class="style7 style11 style12">Search By : </span><?php echo $clasification?></td>
</tr>
<tr>
<td height="37" colspan="2"><p class="style7 style11 style12">
<label>
<input type="radio" name="busqueda" value="1" onclick="ocultarFila(4,true);ocultarFila(5,false); ocultarFila(2,false);ocultarFila(3,false);ocultarF ila(6,false);" />
By Clasification</label>
<label>
<input type="radio" name="busqueda" value="2" onclick="ocultarFila(2,true);ocultarFila(3,true);o cultarFila(4,false);ocultarFila(5,false);ocultarFi la(6,false);" />
Knumber</label>
<label>
<input type="radio" name="busqueda" value="3" onclick="ocultarFila(4,false);ocultarFila(5,false) ;ocultarFila(3,false);ocultarFila(2,false);ocultar Fila(6,true);" />
Description</label>
<br />
</p></td>
</tr>
<tr>
<td width="150"><div align="right" class="style8 style7 style7 style11 style12">KNumber: </div></td>
<td width="225"><input name="search_criteria" type="text" id="search_criteria" size="14" /></td>
</tr>
<tr>
<td><div align="right" class="style7 style11 style12">
<input name="radiobutton" type="radio" value="begins" />
Begins with </div></td>
<td><span class="style7 style11 style12">
<input name="radiobutton" type="radio" value="contains" />
Contains
<input name="radiobutton" type="radio" value="endswith" />
Ends with </span></td>
</tr>
<tr>
<td><div align="right" class="style7 style11 style12">Clasification : </div></td>
<td><span class="style7 style11 style12">
<select onchange="<?php echo $clasification;?>" name="clasification">
<option value=""></option>
<?php RetrieveClasifications();?>
</select>
</span></td>
</tr>
<tr>
<td><div align="right" class="style7 style11 style12">Size : </div>
<div align="right" class="style7 style11 style12"></div></td>
<td><input name="textfield" type="text" size="3" /></td>
</tr>
<tr>
<td><div align="right" class="style7 style11 style12">Description : </div></td>
<td><input name="textfield2" type="text" /></td>
</tr>
<tr>
<td colspan="2"><div align="right">
<input type="submit" name="Submit" value="Search" />
</div></td>
</tr>
</table>
</form>
</div>
</div>
</div>
</body>

</html>
  #2 (permalink)  
Antiguo 13/12/2007, 08:28
 
Fecha de Ingreso: junio-2006
Mensajes: 270
Antigüedad: 17 años, 10 meses
Puntos: 0
Re: Select ONCHANGE??

Poniendo $_POST['clasification']
  #3 (permalink)  
Antiguo 13/12/2007, 08:35
Avatar de agressor  
Fecha de Ingreso: noviembre-2007
Ubicación: Knocking the Death Door..
Mensajes: 368
Antigüedad: 16 años, 5 meses
Puntos: 3
De acuerdo Re: Select ONCHANGE??

Noup nada aun lo que quiero es que cuando selecciones una opcion de las que estan en el select en el mismo formulario sin pasar a otra pagina me diga que seleccion hizo.. osea que cuando seleccione una opcion y luego otra me diga la actual seleccion.. no se si me doy a entender
pero gracias.. se te agradece tu ayuda..
  #4 (permalink)  
Antiguo 13/12/2007, 09:48
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 18 años
Puntos: 2135
Re: Select ONCHANGE??

Eso se hace con javascript para que puedas ver inmediatamente el valor que selecciono, te muevo al foro adecuado.

Saludos.
  #5 (permalink)  
Antiguo 13/12/2007, 10:56
 
Fecha de Ingreso: septiembre-2007
Mensajes: 26
Antigüedad: 16 años, 7 meses
Puntos: 1
Re: Select ONCHANGE??

Para obtener el valor seleccionado deberás usar el value que tiene el value de la opción seleccionada (no el text que se ve de la opción): onchange="alert(this.value)"
  #6 (permalink)  
Antiguo 13/12/2007, 10:58
Avatar de agressor  
Fecha de Ingreso: noviembre-2007
Ubicación: Knocking the Death Door..
Mensajes: 368
Antigüedad: 16 años, 5 meses
Puntos: 3
Re: Select ONCHANGE??

Hola a todos les agradezco la ayuda pero como haria para que se me guardara en una variable..?? mas o menos esto necesito ya que aqui me sale y todo pero necesito guardarlo en una variable para ver que campos mostrar y que no.. les agradezco de antemano...


function verseleccion()
{
var x=document.getElementById("clasification");
alert(x.selectedIndex);
}

<select onchange="verseleccion()" name="clasification">
<option value=""></option>
<?php RetrieveClasifications();?>
</select>
  #7 (permalink)  
Antiguo 13/12/2007, 12:49
Avatar de agressor  
Fecha de Ingreso: noviembre-2007
Ubicación: Knocking the Death Door..
Mensajes: 368
Antigüedad: 16 años, 5 meses
Puntos: 3
De acuerdo Re: Select ONCHANGE??

Muchas gracis solo que me equivoque con respecto al id del SELECT no lo tenia y como javascript trabaja con mas detalle con los ID no me habia percatado de eso pero ya quedo bien muchas gracias por la ayuda a todos.. GRACIAS..!!

Salu2..

function verseleccion()
{
var x=document.getElementById("clasification");
alert(x.selectedIndex);
}

<select onchange="verseleccion()" id="clasification" name="clasification">
<option value=""></option>
<?php RetrieveClasifications();?>
</select>
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:57.