Foros del Web » Programando para Internet » PHP »

select multiple con php

Estas en el tema de select multiple con php en el foro de PHP en Foros del Web. hola a todos. soy nuevo en el foto y kisiera k me ayuden en un problema k tengo. estoy haciendo un select box dinamico. cuando ...
  #1 (permalink)  
Antiguo 21/04/2008, 14:13
(Desactivado)
 
Fecha de Ingreso: abril-2008
Mensajes: 787
Antigüedad: 16 años
Puntos: 7
select multiple con php

hola a todos. soy nuevo en el foto y kisiera k me ayuden en un problema k tengo. estoy haciendo un select box dinamico. cuando doy clic en el primero, se traslada al otro selectbox y me debe mostrar mi consulta el valor del otro select. poer aun asi no me llega el nombre del select.

este es mi codigo.

<?php
include('includes/conexion.php');
?>
<!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>
<script language="javascript" src = "js/script.js"></script>
<script language="javascript" src = "js/ajax.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Busqueda Avanzada</title>
</head>

<body>
<form name = "frmbusavanzada" method = "post" onsubmit="busquedavanzada(document.frmbusavanzada. palabra.value); return false">
<input type="hidden" name="lista2" id = "lista2" value="">
<table width="710" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td>Pais</td>
<td>&nbsp;</td>
<td>Su perfil</td>
</tr>
<tr>
<td width="200">
<select name="pais_1" size="4" multiple style="width: 200px;">
<option value="1">Peru</option>
</select>
</td>
<td width="100">
<button type="button" onclick="copyToList('pais_1','lst_pais_1');">>></button>
<br/>
<button type="button" onclick="copyToList('lst_pais_1','pais_1');"><<</button></td>
<td width="200">
<select name="lst_pais_1" size="4" multiple style="width: 200px;">
</select>
</td>
</tr>
<tr>
<td>Tipo de negocio </td>
<td>&nbsp;</td>
<td>Su perfil </td>
</tr>
<tr>
<td>
<select name="cbotipo" size="4" multiple style="width: 200px; height:150px;">
<?php
$sql = "select * from omp_tiponegocio";
$rpta = mysql_query($sql) or die(mysql_error());
while($fila = mysql_fetch_array($rpta)){
echo "<option value = ".$fila['idtiponegocio'].">".utf8_encode($fila['descripcion'])."</option>";
}
?>
</select>
</td>
<td width="100">
<button type="button" onclick="copyToList('cbotipo','cbotiponeg')">>></button>
<br/>
<button type="button" onclick="copyToList('cbotiponeg','cbotipo')"><<</button> </td>
<td width="200">
<select name="cbotiponeg" size="4" multiple style="width: 200px; height:150px;">
</select>
</td>
</tr>
<tr>
<td>Giro de negocio </td>
<td>&nbsp;</td>
<td>Su perfil</td>
</tr>
<tr>
<td width="200">
<select name="giro" onchange="ver_subgiro1(this.value);" size="4" multiple style="width: 200px; height:150px;" >
<?php
$sql_1 = "select * from omp_gironegocio";
$rpta_1 = mysql_query($sql_1) or die(mysql_error());
while($fila_1 = mysql_fetch_array($rpta_1)){
echo "<option value = ".$fila_1['idgironegocio'].">".utf8_encode($fila_1['descripcion'])."</option>";
}
?>
</select>
</td>
<td width="100">
<button type="button" onclick="copyToList('giro','cbogiro')">>></button>
<br/>
<button type="button" onclick="copyToList('cbogiro','giro')"><<</button>
</td>
<td width="200">
<select name="cbogiro" size="4" multiple style="width: 200px; height:150px;">
</select>
</td>
</tr>
<tr>
<td>Subgiro de negocio </td>
<td>&nbsp;</td>
<td>Su perfil </td>
</tr>
<tr>
<td>
<div id = "div_subgiro1" align="left">
<select name="codigo1" size="4" multiple id="div_subgiro1" style="width: 200px; height:150px;" disabled="disabled">
</select>
</div>
</td>
<td width="100">
<button type="button" onclick="copyToList('codigo1','subgiro_all')">>></button>
<br/>
<button type="button" onclick="copyToList('subgiro_all','codigo1')"><<</button>
</td>
<td width="200">
<select name="subgiro_all" size="4" multiple style="width: 200px; height:150px;">
</select>
</td>
</tr>
<tr>
<td>Rango de precio </td>
<td>&nbsp;</td>
<td>Su perfil </td>
</tr>
<tr>
<td>
Seleccione un rango de montos para precio de venta.<br//>
Para ver todos los rangos, déjelo en ceros. </td>
<td>&nbsp;</td>
<td valign="top"><table width="232" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="85">Desde</td>
<td width="147">
<select name="cborango1">
<?php
$sql_2 = "SELECT * FROM omp_rangoprecio";
$rpta_2 = mysql_query($sql_2);

while($fila_2 = mysql_fetch_array($rpta_2)){
echo "<option value = ".$fila_2['idrangoprecio'].">$ ".$fila_2['desde']."</option>";
}
?>
</select> </td>
</tr>
<tr>
<td>hasta</td>
<td>
<select name="cborango2">
<?php
$sql_2 = "SELECT * FROM omp_rangoprecio";
$rpta_2 = mysql_query($sql_2);

while($fila_2 = mysql_fetch_array($rpta_2)){
echo "<option value = ".$fila_2['idrangoprecio'].">$ ".$fila_2['hasta']."</option>";
}
?>
</select>
</td>
</tr>
</table></td>
</tr>
<tr>
<td>Palabras Clave </td>
<td>&nbsp;</td>
<td>Su perfil </td>
</tr>
<tr>
<td>Nota: Si desea ser mas especifico sobre su búsqueda introduzca las palabras de su interés, separadas por comas.</td>
<td>&nbsp;</td>
<td valign="top"><input type="text" name="palabra" /></td>
</tr>
</table>
<table width="710" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><center><button type="submit">Buscar</button></center></td>
</tr>
</table>


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

el codigo js de los select multiple:

// select multiple

function copyToList(from,to)
{
fromList = eval('document.forms[0].' + from);
toList = eval('document.forms[0].' + to);
if (toList.options.length > 0 && toList.options[0].value == 'temp')
{
toList.options.length = 0;
}
var sel = false;
for (i=0;i<fromList.options.length;i++)
{
var current = fromList.options[i];
if (current.selected)
{
sel = true;
if (current.value == 'temp')
{
alert ('No se puede pasar de este texto!');
return;
}
txt = current.text;
val = current.value;
toList.options[toList.length] = new Option(txt,val);
fromList.options[i] = null;
i--;
}
}
if (!sel) alert ('No ha seleccionado ninguna opcion!');
}

function allSelect()
{
List = document.forms[0].chosen;
if (List.length && List.options[0].value == 'temp') return;
for (i=0;i<List.length;i++)
{
List.options[i].selected = true;
}
}
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 00:20.