Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/12/2012, 08:48
carlosuc99
 
Fecha de Ingreso: junio-2011
Mensajes: 342
Antigüedad: 12 años, 10 meses
Puntos: 5
Exclamación Respuesta: Problema con menús dependendientes

Os dejo los archivos completos, con lo que me has dicho no he sido capaz de arreglarlo:

new_aircraft.php

Código PHP:
<!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">
<head>
<link rel="STYLESHEET" type="text/css" href="./style.css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Insert Aircraft</title>
</head>
<body>
<script>
//Ajax Script
function require(){
    try{
    req = new XMLHttpRequest();
    }catch(err1){
        try{
        req = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(err2){
            try{
            req = new ActiveXObject("Msxml2.XMLHTTP");
            }catch(err3){
            req = false;
            }
        }
    }
return req;
}


var request = require();

function callAjax(){
var ramdom = parseInt(Math.random()*999999999);
valor = document.getElementById("numberclasses").value;
var url="classes.php?Value="+valor+"&r="+ramdom;
request.open("GET",url,true);
request.onreadystatechange = answerAjax;
request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
request.send(null);
}

function answerAjax(){

    if(request.readyState==4){
        if(request.status==200){
        //alert(request.responseText);
        document.getElementById("classes").innerHTML=request.responseText;
        }else{
        alert("ha ocurrido un error"+request.statusText);
        }
    }
}

</script>
<?

$boton 
$_POST['enviar'];
$nombre $_POST['nombre'];
$precio $_POST['precio'];
$pax $_POST['pax'];
$ICAO $_POST['ICAO'];

if(
$boton == 'Insertar')
{
    include(
'./db.inc.php');
    
    
$ICAO strtoupper($ICAO);        
    
mysql_query("INSERT INTO flota(ICAO, nombre, precio, capacidad) VALUES('$ICAO', '$nombre', '$precio', '$pax')") or die('<h4 style="color: red;">Ha habido un problema con la insercion.</h4>');
    
    
mysql_close();
    
    echo 
'<h3 style="color: green;">Aeronave adquirida correctamente.<h3/>';
}
else
{
    
?>
    <form action="insertar-modelo.php" method="post" enctype="application/x-www-form-urlencoded">
    <table>
    <tr><td class=Forms>ICAO: </td><td><input type="text" value="" name="ICAO" /></td></tr>
    <tr><td class=Forms>Name: </td><td><input type="text" value="Airbus A320" name="nombre" /></td></tr>
    <tr><td class=Forms>Price: </td><td><input maxlength="9" value="1000000" type="text" name="precio" /> €</td></tr>
    <div id="dep">
    <tr><td class=Forms>Number Classes: </td></td><td><select name="numberclasses" id="numberclasses" onchange="callAjax()">
          <option>Select Number of Classes</option>
          <?php
          
echo'<option value="1">One</option>';
          
?>
    </select></td></tr>
    </div>


<div id="classes">
    <tr><td class=Forms>First Class: </td><td><input maxlength="3" value="150" type="text" name="classes" id="classes"/></td></tr>
</div>

    <tr><td class=Forms>Capacidad: </td><td><input maxlength="3" value="150" type="text" name="pax" /> pasajeros</td></tr>
    </table><br />
    <input type="submit" name="enviar" value="Insertar"/>
    </form>
    <?
}
?>
</body>
</html>

classes.php

Código PHP:
<?php
$value 
$_GET['Value'];

if(
$value == 1){


    
?>



    <tr><td class=Forms>First Class: </td><td><input maxlength="3" value="150" type="text" name="pax" /></td></tr>

    
<?php
}
  
?>
Ayuda por favor!