Ver Mensaje Individual
  #4 (permalink)  
Antiguo 26/08/2009, 14:59
turfeano
 
Fecha de Ingreso: diciembre-2008
Mensajes: 190
Antigüedad: 15 años, 4 meses
Puntos: 6
Respuesta: combobox y datagrid dinamicos con PHP

Código HTML:
<html>
<head>
<title>AJAX</title>
<script language="javascript">
function ajaxobj() {
        try {
                _ajaxobj = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
                try {
                        _ajaxobj = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (E) {
                        _ajaxobj = false;
                }
        }

        if (!_ajaxobj && typeof XMLHttpRequest!=’undefined’) {
                _ajaxobj = new XMLHttpRequest();
        }

        return _ajaxobj;
}

function sinc(URL,DIV) {
        ajax = ajaxobj();
        ajax.open("GET", URL, true);

        ajax.onreadystatechange = function() {
                switch(ajax.readyState) {
                        case 1:
                                document.getElementById(DIV).innerHTML = "Cargando…";
                                break;
                               
                        case 4:
                                document.getElementById(DIV).innerHTML = ajax.responseText;
                                break;
                }
        }
        ajax.send(null);
}
</script>
</head> 
Eso es un ejemplo de llamar al httprequest
luego el body

Código HTML:
<body>
<div id="AJAX">
<!-------ACA SE VE EL GRID DINAMICO-------------->
</div>
<br>
<input height="20px" type="button" onClick="sinc('GRID.PHP?DATO1=XXX&DATO2=XXX','AJAX');" value="boton">

</body>
</html> 
claro que ese "grid.php?dato.." lo tendras q ir armando con javascript en una variable
del tipo
var urlfinal;
en un select por ejemplo pones onchange="armar_url(this.value)"
y la funcion
function armar_url(dato){
var urlfinal .= "datodelsect=" + dato;

}

nose no me acuerdo de la concatenaciond e javascript pero esa es la idea




y grid php tendra tus consultas y eso obviamente..

Código PHP:
<?php 
echo $_GET['DATO1']." y dato2 es ".$_GET['DATO2'];
?>

Última edición por turfeano; 26/08/2009 a las 15:19