zero_21_21
unread,Dec 9, 2008, 5:35:29 PM12/9/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ajax-es
Hola a todos, soy nuevo en este grupo ... y tengo el siguiente
inconveniente:
Tengo un codigo ajax que segun lo investigado deberia enviar el valor
del primer combobox a un archivo php que recibira estas variables para
utilizarlas en un query, insert..etc... pero resulta que no esta
realizando esto y el responseText no esta devolviendo nada, no he
podido identificar el error y por eso recurro a este grupo aqui estan
los codigos:
Codigo HTML
<form name="DigitaAfiliacion" action="index.php?seccion=CCFORMU"
method="POST">
<table border="3" align="center">
<tr>
<td>
<input type="hidden" name="afiliacion" id="afiliacion" value="">
<table border="0" width="100%">
<tr class="TH1">
<td align="center" colspan="6">
<br><b>FORMULARIO DE AFILIACIÓN E INSCRIPCIÓN REGIMEN CONTRIBUTIVO</
br></td>
</tr>
<tr class="TH">
<td>
<b>Tipo Cotizante
</td>
<td>
<-- En el onchange se llama la funcion de javascript
o ajax!-->
<select name="TipoCot" id="idTipoCot" style=width:360px
onchange="cargarContenido()">
<? creacomboxconarray($arTipoCotizante,$caTipoCot,0,1);?>
</select>
</td>
<-- Aqui aparece los mensajes del innerHTML!--
>
<td class="TH" colspan="2"><div id="idajax"></td>
</tr>
<tr class="TH">
<td class="bordes">
<b>Tipo Identificación</div>
</td>
<td>
<select disabled=disabled name="cbTipoId" id="idTipoId"> <?
clValidarForma::fnValidarTipoId($arTipoDocumentoAfiliado,$caTipoId);?>
</select>
</td>
<td>
<b>Número
</td>
<td colspan="2">
<input type="text" name="txtNumero" id="idNumero" value="<?pSession
($nuNumeroId);?>">
</td>
</tr>
</table>
</form>
CODIGO AJAX
function Ajax()
{
/* Crea el objeto AJAX. Esta funcion es generica para cualquier
utilidad de este tipo, por
lo que se puede copiar tal como esta aqui */
var xmlhttp=false;
try
{
// Creacion del objeto AJAX para navegadores no IE
xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
// Creacion del objet AJAX para IE
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(E)
{
if (!xmlhttp && typeof XMLHttpRequest!='undefined') xmlhttp=new
XMLHttpRequest();
}
}
return xmlhttp;
}
function cargarContenido(){
//Div donde estaran los innerHTML
var SelectOrigen=document.getElementById('idajax');
// variable para activar un combobox
var SelectDestino=document.getElementById('idTipoId');
//Capturo el valor Seleccionado en el combobox
var Selected=document.getElementById('idTipoCot').options
[document.getElementById('idTipoCot').selectedIndex].value;
//Objeto ajax
ajax=Ajax();
ajax.open('POST','../Scripts/modulo/Nuevo/js/pruebas.php?',true);
ajax.onreadystatechange=function() {
if(ajax.readyState==1){
//Escribo en el div
SelectOrigen.innerHTML="Cargando........";
//Activo combobox
SelectDestino.disabled=false;
}
else if (ajax.readyState == 4 ) {
if(ajax.status==200)
{
alert(ajax.responseText);
}
else if(ajax.status==404)
{
SelectOrigen.innerHTML = "La direccion no existe";
}
else
{
SelectOrigen.innerHTML = "Error: ".ajax.status;
}
}
}
//Realizo envio diciendo que es una forma
//ajax.setRequestHeader('Content-Type','application/x-www-form-
urlencoded');
ajax.send('var1='+Selected);
}
CODIGO PHP
<?
print_r("Post".$_POST);
?>