Estoy realizando una rutina donde tengo un textbox y con un enlace, en este caso una imagen que tiene el evento onclick, que cuando se presiona muestra la relacion de ciudades, todo esto dentro un div.
Hasta aca todo ok. pero lo que me gustaria (ya que he visto en otras web) que cuando seleccione cualquier ciudad , éste nombre(ciudad), se me envie al value del text box y el div desaparezca(se cierre) cuando presiono sobre la ciudad.
Como se podria hacer esto ???????????
<?
include_once('Bbdd.php');
$bd = new Bbdd();
$SQL_Provincias = 'SELECT * FROM provincias';
$EJEC_SQL_Provincias = $bd->bbdd_query($SQL_Provincias);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
Código:
</head><script language="Javascript"> function aparecer(id) { var d = document.getElementById(id); d.style.display = "block"; d.style.visibility = "visible"; } function ocultar(id) { var d = document.getElementById(id); d.style.display = "none"; d.style.visibility = "hidden"; } window.onload = function () { //Al cargar la página se oculta el div de consulta ocultar("capaConsultar"); } </script>
<body>
Destino <input type="text" name="textfield" />
<a href="#" onclick="aparecer('capaConsultar')"><img src="arrow1.gif" border="0" /></a>
<div id="capaConsultar" style="width:200px; border:solid 1px #ccc;">
<?
while($filas = $bd->bbdd_fetch($EJEC_SQL_Provincias)){
?>
<ul>
<li><a href="<?=$_SERVER['PHP_SELF']?>?id=<?=$filas["descripcion"]?>"><?=$filas["descripcion"]?></a></li>
</ul>
<?
}
?>
</div>
</body>
</html>[/PHP]
Gracias y saludos a todos.