Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Otros entornos y lenguajes > PHP
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

 
 
Herramientas Buscar en Tema Desplegado
  #2  
Antiguo 11-07-2007
jgutti jgutti is offline
Miembro
 
Registrado: may 2003
Posts: 189
Poder: 24
jgutti Va por buen camino
Gabriel, esto lo puedes hacer con ajax+php, adjunto ejemplo:

# index.php
<?
$hostname_testing = "localhost";
$database_testing = "testing";
$username_testing = "testing";
$password_testing = "testing";
$testing = mysql_connect($hostname_testing, $username_testing, $password_testing) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_testing, $testing);
$query_combo1 = "SELECT * FROM municipios";
$combo1 = mysql_query($query_combo1, $testing) or die(mysql_error());
$row = mysql_fetch_assoc($combo1);
?>
<html>
<head>
<title>Combos</title>
<script language="JavaScript" type="text/javascript" src="ajax.js"></script>
</head>
<body>
<form name="f1" method="post">
<select name="municipios" onChange="optionMuni();">
<option value="0">[ Seleccione ]</option>
<? do { ?>
<option value="<? echo $row['id_muni']?>"><? echo $row['nom_muni']?></option>
<? } while ($row = mysql_fetch_assoc($combo1)); ?>
</select>
<div id="localidad"><select><option>[ Seleccione ]</option></select></div>
</form>
</body>
</html>
<? mysql_free_result($combo1); ?>


# ajax.js
function objetoAjax(){
var xmlhttp=false;
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
xmlhttp = new XMLHttpRequest();
}
return xmlhttp;
}
function optionMuni(){
divResultado = document.getElementById('localidad');
id_muni=document.f1.municipios.value;
ajax=objetoAjax();
ajax.open("POST", "localidad.php",true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
divResultado.innerHTML = ajax.responseText
}
}
ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajax.send("id_muni="+id_muni)
}


# localidad.php
<?
$hostname_testing = "localhost";
$database_testing = "testing";
$username_testing = "testing";
$password_testing = "testing";
$testing = mysql_connect($hostname_testing, $username_testing, $password_testing) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_testing, $testing);
mysql_select_db($database_testing, $testing);
$query_localidades = "SELECT localidades.id_local, localidades.nom_local FROM localidades WHERE localidades.id_muni=". $_POST['id_muni'];
$localidades = mysql_query($query_localidades, $testing) or die(mysql_error());
$row = mysql_fetch_assoc($localidades);
?>
<select name="localidades">
<option value="0">[ Seleccione ]</option>
<? do { ?>
<option value="<? echo $row['id_local']?>"><? echo $row['nom_local']?></option>
<? } while ($row = mysql_fetch_assoc($localidades));?>
</select>
<? mysql_free_result($localidades); ?>
Responder Con Cita
 


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Interactuar con campos en documento pdf jhges Varios 2 18-07-2007 12:11:14
Interactuar pagina web con delphi manuweb Varios 6 20-12-2006 11:36:10
combos BoNnY0301 OOP 5 06-05-2006 09:07:30
Interactuar Con Servicio de Windows Enan0 API de Windows 4 27-01-2006 17:31:38
Interactuar con una web Masu Internet 1 03-07-2005 00:37:08


La franja horaria es GMT +2. Ahora son las 06:42:23.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi