I got this code that i need to fix, it is supposed to be 5 chained combo box once you fill the first one the next one should start working (one after the other). But once i try to click on the first one it simply resets itself making the other 4 usseles.
This is the code:
<?php
require_once('Connections/data.php');
if (!isset($_SESSION)) {
session_start();
}
$a=$_SESSION['MM_Username'];
mysql_select_db($database_data, $data);
$query_define2 = "SELECT * FROM usuario where correo='".$a."'";
$define2 = mysql_query($query_define2, $data) or die(mysql_error());
$row_define2 = mysql_fetch_assoc($define2);
$totalRows_define2 = mysql_num_rows($define2);
if(!empty($vars_sedes)){
mysql_select_db($database_data, $data);
$query_define3 = "SELECT * FROM usuario where correo='".$a."'";
$define3 = mysql_query($query_define3, $data) or die(mysql_error());
$row_define3 = mysql_fetch_assoc($define3);
$totalRows_define3 = mysql_num_rows($define3);
}
if($row_define2['nivel_acceso']!=1){
$valor=" inner join subsedes on sedes.IDSede=subsedes.IDSede inner join usuario on usuario.IDSubSede=subsedes.IDSubSede where sedes.eliminado=0 and usuario.IDSubSede='".$row_define2['IDSubSede']."' order by NombreSede";
$valor2="inner join usuario on usuario.IDSubSede=subsedes.IDSubSede where subsedes.eliminado=0 and usuario.IDSubSede='".$row_define3['IDSubSede']."' and subsedes.IDSede='$vars_sedes' order by NombreSubSede";
}else{
$valor=" where sedes.eliminado=0 order by sedes.NombreSede";
$valor2="where subsedes.eliminado=0 and subsedes.IDSede='$vars_sedes' order by NombreSubSede";
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<?php // SE DECLARAN LOS ESTILOS ?>
<style type="text/css">
<!--
@import url("txt-ucv.css");
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #ffffff;
}
-->
</style>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
// SE CREA LA FUNCION DEL AJAX
function nuevoAjax(){
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;
}
// FUNCION PARA LLAMAR A LA FUNCION CREADORA DEL AJAX
function AddImages(vars){
var IDImages=document.getElementById('IDImages');
var conjunto="";
var vec=vars.split(",");
for(i=0;i<(vec.length-1);i++){
var varss=document.getElementById(vec[i]).value;
conjunto+="vars_"+vec[i]+"="+varss+"&";
}
// SE CREA LA VARIABLE QUE CONTIENE A "xmlhttp"
ajax=nuevoAjax();
ajax.open("GET", "inc-cargador7-1.php?"+conjunto,true);
ajax.open("POST", "inc-cargador7-1.php?"+conjunto,true);
ajax.onreadystatechange=function() {
if (ajax.readyState==4) {
IDImages.innerHTML = ajax.responseText;
}
}
ajax.send(null);
}
</script>
<?php
//SE CREA LA CONEXION PARA LOS COMBOS
require_once("includes/clase_base_datosop.php");
// SE CREA LA CLASE QUE MUESTRA LOS VALORES DE LA LISTA
class DB_ListBoxst extends DB_mysql {
var $nombrelist;
function CreaListasOpcione($Consultasql){
if( ($this->result=@mysql_query($Consultasql,$this->conexion))&& (!empty($Consultasql)) ){
if($this->selecciona_restrictivo($Consultasql)>=1){
while($datos=mysql_fetch_array($this->result)){
if ($datos['nombre']!=""){
$nombres=$datos['nombre'];
}else{
$nombres=$datos['nombre2'];
}
$ta.="<option value=\\"$datos[valor]\\">".ucfirst($nombres)."</option>";
}
}else{
$ta="<option value=\\"\\" select>Seleccione "."</option>";
}
return $ta;
}else{
echo $this->errores("5");
exit;}
}
function CreaListas($nombrelist,$sql,$validacionSQL,$ajax,$class_styles){
$this->nombrelist=$nombrelist;
$ta="<select name=\\"$this->nombrelist\\" class=\\"textFields01\\" id=\\"$this->nombrelist\\" onChange=\\"$ajax\\" class=\\"$class_styles\\">";
$ta.=$this->CreaListasOpcione($validacionSQL);
$ta.=$this->CreaListasOpcione($sql);
$ta.="</select>";
return $ta;
}////
}
$objeto_representante=new DB_ListBoxst();// the password and such are in the code, but cant give them.
$objeto_representante->conectar("localhost","","");
$objeto_representante->selecciona_baseDatos("");
?>
<link href="styles/ccs-intranet-adv.css" rel="stylesheet" type="text/css" />
<div id="IDImages">
<table width="100%" border="0" cellpadding="3" cellspacing="2">
<tr>
<td width="171" class="textoTitulo03"><div align="left">Campus:</div></td>
<td width="806"><div align="left">
<?php
// SE CONSTRUYEN COMBOS PARA EL AJAX
echo $operacionSQLs=$objeto_representante->CreaListas("sedes","select distinct sedes.IDSede as valor, sedes.NombreSede as nombre from sedes $valor","select sedes.IDSede as valor, sedes.NombreSede as nombre from sedes where sedes.IDSede='".$vars_sedes."'","AddImages('sedes,')","")."<br>";
?>
</div></td>
</tr>
<tr>
<td class="textoTitulo03">Facultad:</td>
<td><div align="left">
<?php
$operacionSQL1s=$objeto_representante->CreaListas("subsedes","select distinct distinct subsedes.IDSubSede as valor,subsedes.NombreSubSede as nombre from subsedes $valor2","select subsedes.IDSubSede as valor,subsedes.NombreSubSede as nombre from subsedes where subsedes.IDSubSede='".$vars_subsedes."' and subsedes.eliminado='0'","AddImages('sedes,subsedes,')","")."<br>";
$new_operacionSQL1s=$operacionSQL1s;
echo $new_operacionSQL1s;
?>
</div></td>
</tr>
<tr>
<td class="textoTitulo03">Escuela</td>
<td align="left"><?php
$operacionSQL1s=$objeto_representante->CreaListas("escuelas","select IDEscuela as valor,NombreEscuela as nombre from escuelas where eliminado='0' and IDSubSede='".$vars_subsedes."' order by nombre","select IDEscuela as valor,NombreEscuela as nombre from escuelas where IDEscuela='".$vars_escuelas."'","AddImages('sedes,subsedes,escuelas,')","")."<br>";
$new_operacionSQL1s=$operacionSQL1s;
echo $new_operacionSQL1s;
?></td>
</tr>
<tr>
<td class="textoTitulo03">Edificio:</td>
<td><div align="left">
<?php
$operacionSQL1s=$objeto_representante->CreaListas("edificio","select distinct edificios.IDEdificio as valor,edificios.NombreEdificio as nombre from edificios inner join pisos on edificios.IDedificio=pisos.IDEdificio where edificios.eliminado='0' and pisos.IDEscuela='".$vars_escuelas."' order by nombre","select edificios.IDEdificio as valor,edificios.NombreEdificio as nombre from edificios where edificios.IDEdificio='".$vars_edificio."'","AddImages('sedes,subsedes,escuelas,edificio,')","")."<br>";
$new_operacionSQL1s=$operacionSQL1s;
echo $new_operacionSQL1s;
?>
</div></td>
</tr>
<tr>
<td class="textoTitulo03">Piso:</td>
<td align="left"><?php
$operacionSQL1s=$objeto_representante->CreaListas("IDPiso","select IDPiso as valor,NombrePiso as nombre from pisos where IDEdificio='".$vars_edificio."' order by nombre","select IDPiso as valor,NombrePiso as nombre from pisos where IDPiso='".$vars_IDPiso."'","AddImages('sedes,subsedes,escuelas,edificio,IDPiso,')","")."<br>";
$new_operacionSQL1s=$operacionSQL1s;
echo $new_operacionSQL1s;
?></td>
</tr>
<?php if(!empty($_REQUEST['idCuarto'])){ ?>
<tr>
<td class="textoTitulo03">Cuarto de Cableado :</td>
<td align="left"><?php
$operacionSQL1s=$objeto_representante->CreaListas("cuarto_cableado","select IDCuartoDeCableado as valor,NombreCuartoDeCableado as nombre from cuartosdecableado where cuartosdecableado.IDPiso='".$vars_IDPiso."' order by cuartosdecableado.NombreCuartoDeCableado","select cuartosdecableado.IDCuartoDeCableado as valor,cuartosdecableado.NombreCuartoDeCableado as nombre from cuartosdecableado where cuartosdecableado.IDCuartoDeCableado='".$vars_cuarto_cableado."'","AddImages('sedes,subsedes,escuelas,edificio,IDPiso,cuarto_cableado,')","")."<br>";
$new_operacionSQL1ss=$operacionSQL1s;
echo $new_operacionSQL1ss;
?></td>
</tr>
<?php } ?>
</table>
</div>
Do you have any idea why???.
Thx for any answer you could provide.