Ver Mensaje Individual
  #3 (permalink)  
Antiguo 21/10/2008, 09:24
danteq
 
Fecha de Ingreso: septiembre-2008
Mensajes: 23
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Se me repite el combo

GatorV, muchas gracias por responderme y por sacarme de la duda pero no se me ocurren soluciones para este problema

mi pagina html es asi:

<select name="cboProducto" id="cboProducto" onchange="javascript:cargarCombo('combo.php', 'cboProducto', 'div_combodependiente')" >
<option value="">Selecciona</option>
<?php
while ($datos= pg_fetch_array($resultado))
{
echo "<option value='$datos[des_tip]'>$datos[des_tip]</option>";
}
?>
</select>


<div id="div_combodependiente">
<?php $valor=$_REQUEST['Id']; ?>
<input name="txtValor" type="text" id="txtValor" value="<?php echo $valor;?>" />

</div>

Y el archivo ajax tiene lo siguiente:

var peticion = false;
var testPasado = false;
try {
peticion = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
peticion = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
peticion = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
peticion = false;
}
}
}
if (!peticion)
alert("ERROR AL INICIALIZAR!");

function cargarCombo (url, comboAnterior, element_id) {

var element = document.getElementById(element_id);

var valordepende = document.getElementById(comboAnterior)
var x = valordepende.value

var fragment_url = url+'?Id='+x;

element.innerHTML = '<img src="loading.gif" />';

peticion.open("GET", fragment_url);

peticion.onreadystatechange = function() {
if (peticion.readyState == 4) {

element.innerHTML = peticion.responseText;
}
}
peticion.send(null);
}

Gracias y espero no ser una molestia y por favor me puedan ayudar ya q cuando ejecuto este codigo se me repite el combo