Dropdown dependent upon DIV loading

Asked

Viewed 54 times

2

I have in the file Fields.php the code below, which selects the company and according to the request will load divs with specific fields for that request. On the first request, I have to load the Head Office and it is loaded according to the selected company code (TT or PA). If the selected company is TT the data from the menu dropdown should be 2998 w 2378 if PA is should be 9867 and 5678, these data are saved in a table. The problem is that like the DIV with the fields are loaded only after the choice of the request, both by JavaScript/JQuery, how much for VBScript or $_POST the value of the Company is not drawn. Just to make this clear script that I have fuciona for 99% of the cases that we take here but generally the dropdown "son" and "father" are within it div. Any idea? There are things that are from Framework and standardized, I need to leave the scripts in different files and the selects are also like that.

$sql = "SELECT CONCAT(Company,' - ',Nome) AS Valor, CONCAT(Company,' - ',Nome) AS Texto FROM Company WHERE Pais LIKE '$pais' AND (Company LIKE 'TT%' OR Company LIKE 'PA%') ORDER BY Valor";
new SelectField("company","Company","",260,"onChange=LoadPlant()",$idioma,"line","","mandatory;",$sql,"DB_".$dbPath."Company","show");



$sql = "SELECT Codigo AS Valor, Opcao AS Texto FROM Solicitacao WHERE Pais LIKE '$pais' ORDER BY Valor";
new SelectField("solicitacao","Tipo da Solicitação","",260,"onChange=Solicitcao_OnChange()",$idioma,"line","","mandatory;",$sql,"DB_".$dbPath."Company","show");

$idSolicitacao = "01"; 
echo "<div id=$idSolicitacao>";

$sql = "SELECT Opcao AS Valor, Opcao AS Texto FROM plant_material WHERE Market = 'xxx'";
new SelectField($idSolicitacao."plant","Plant (Material/Destination)","",260,"",$idioma,"line","","mandatory;",$sql,"DB_".$dbPath."Forms_96","show");     


echo "</div>";

In another file the LoadPlant.php have

$company = utf8_decode($_POST["company"]);

$sql = "SELECT Opcao FROM plant_material WHERE Market = '$company' ORDER BY Opcao";
$query = mysql_query($sql);

echo "<option value=''>-</option>";    
while($rs = mysql_fetch_assoc($query))
{
    echo "<option value='$rs[Opcao]'>".htmlentities("$rs[Opcao]")."</option>";
}  

And in the archive Function.js have

//<<<<< LoadPlant() >>>>>
function LoadPlant()
{   
    var company = $("#company").val();
    var idSolicitacao = $("#Solicitacao").val();

    $.post(
        "Scripts/LoadPlant.php",
        {company:company},
        function(valor)
        {                   
            $("select[name=plant]").html(valor);    
        }
    );
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.