JavaScript - Listbox con javascript

 
Vista:

Listbox con javascript

Publicado por Alexis Barraza (1 intervención) el 04/11/2010 22:42:07
hola amigos... quisiera molestarlos, lo que pasa es que estoy haciendo un pequeño sistema de gestión de Biblioteca y cuando el usuario escoja un libro necesito que un listbox se llene con los folios del libro que estan en una BD. El codigo de la pagina es el sgte.

<html>
<head>
<title>Listado Libros</title>
<script>
function pasadatos(id, texto, autor){
opener.document.prestamo.id_libro1.value = id
opener.document.prestamo.libro1.value = texto
opener.document.prestamo.autor1.value = autor
window.close()
}
</script>
</head>

<body>

<table width="1081" border="1">
<tr align="center" valign="middle">
<th width="8" height="32" bgcolor="#999999" scope="col"><h3> </h3></th>
<th width="586" bgcolor="#999999" scope="col"><h3>Nombre Del Libro</h3></th>
<th width="333" bgcolor="#999999" scope="col"><h3>Autor</h3></th>
<th width="126" bgcolor="#999999" scope="col"><h3>Ubicación</h3></th>
<th width="126" bgcolor="#999999" scope="col"><h3>Total</h3></th>
<th width="126" bgcolor="#999999" scope="col"><h3>Prestadas</h3></th>
<th width="126" bgcolor="#999999" scope="col"><h3>Disponibles</h3></th>
</tr>
<?php
include "conexion.php";
$nom_libro=$_GET['libro'];
$nom_autor=$_GET['autor'];
$nom_libro = strtoupper($nom_libro);
$nom_autor = strtoupper($nom_autor);
if ($nom_libro <> "" and $nom_autor <> ""){
$sql = "select a.nom_autor, t.nom_titulo, c.ubicacion, t.id_titulo from copias c inner join ( titulos t inner join ( obras at inner join autores a on (a.id_autor=at.id_autor)) on (at.id_titulo=t.id_titulo)) on (t.id_titulo=c.id_titulo) where ucase(t.nom_titulo) like '%$nom_libro%' and ucase(a.nom_autor) like '%$nom_autor%'";
}
elseif($nom_libro<>"" and $nom_autor==""){
/*$sql = "select a.nom_autor, t.nom_titulo, c.ubicacion, t.id_titulo from copias c inner join ( titulos t inner join ( obras at inner join autores a on (a.id_autor=at.id_autor)) on (at.id_titulo=t.id_titulo)) on (t.id_titulo=c.id_titulo) where ucase(t.nom_titulo) like '%$nom_libro%'";*/
$sql ="SELECT copias_por_titulo.id_obra, copias_por_titulo.nom_autor, copias_por_titulo.nom_titulo, copias_por_titulo.ubicacion, copias_por_titulo.id_titulo, copias_por_titulo.total, copias_prestadas.prestadas, (copias_por_titulo.total - copias_prestadas.prestadas) AS disponibles
FROM
copias_por_titulo
Left Join copias_prestadas ON copias_por_titulo.id_obra = copias_prestadas.id_obra where ucase(copias_por_titulo.nom_titulo) like '%$nom_libro%'";

}
elseif($nom_libro=="" and $nom_autor<>""){
$sql = "select a.nom_autor, t.nom_titulo, c.ubicacion, t.id_titulo from copias c inner join ( titulos t inner join ( obras at inner join autores a on (a.id_autor=at.id_autor)) on (at.id_titulo=t.id_titulo)) on (t.id_titulo=c.id_titulo) where ucase(a.nom_autor) like '%$nom_autor%'";
}

$color="#D3EFFE";
//echo $sql;
$res=mysql_query($sql);
while($row = mysql_fetch_array($res)){
echo '<tr>';
echo '<td bgcolor="'.$color.'">'.'<img src="imagenes/enviar.jpg" onClick="pasadatos('."'".$row[0]."'".','."'".$row[1]."'".','."'".$row[2]."'".')"/>'.'</td>';
echo '<td bgcolor="'.$color.'">'.$row[2].'</td>';
echo '<td bgcolor="'.$color.'">'.$row[1].'</td>';
echo '<td bgcolor="'.$color.'">'.$row[3].'</td>';
echo '<td bgcolor="'.$color.'">'.$row[5].'</td>';
echo '<td bgcolor="'.$color.'">'.$row[6].'</td>';
echo '<td bgcolor="'.$color.'">'.$row[7].'</td>';
echo '</tr>';
if($color=="#D3EFFE"){
$color= "#A2DDFD";
}else{
$color= "#D3EFFE";
}

}


?>
</table>
</body>
</html>

Debajo de la etiqueta <title> se escuentra el javascript y es ahi donde debo poner el codigo para que se llene el listbox, Por favor, si alguien sabe como hacerlo se lo agradecer'ia mucho... Saludos.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder