Link to home
Start Free TrialLog in
Avatar of Eduardo Fuerte
Eduardo FuerteFlag for Brazil

asked on

How to make a 2nd. combo to use the option choosed at the 1st combo?

Hi Experts!

How to make a 2nd. combo to use the option choosed at the 1st combo?

Accordingly to the code bellow, the way it's coded the 2nd. combo doesn't use the 1st. combo parameter.


<?php

....

    //----------Code start Combo (DSGER Despesa Hierárquica)--------------------------------------------
  $nivel=1;    // default parameter

 $sql1 = "select sb_dge, dge_info, substr(descricao,1,25) as descricao from dsger 
             where tipo=2 and nivel=".$nivel." order by descricao;";

    // Configurar o nivel:
     $query1 = mysql_query($sql1);
     while ( $results1[] = mysql_fetch_object ( $query1 ) );
     array_pop ( $results1 );
    //----------Final Combo 2-------------------------------------------------------------------------

....

<br/>
/////// 1st. Combo that furnish the parameter "nível" //////
Nivel Totalizador Despesa:
<select name="nivel">
    <option value="1">    1     </option>
    <option value="2">    2     </option>
</select>

<?php
   //After choosen 1st. parameter

    //----------Inicio Combo 2 (DSGER Despesa Hierárquica)--------------------------------------------

     echo "Nivel....".$nivel;

     $sql1 = "select sb_dge, dge_info, substr(descricao,1,25) as descricao from dsger 
             where tipo=2 and nivel=".$nivel." order by descricao;";

    // Configurar o nivel:
     $query1 = mysql_query($sql1);
     while ( $results1[] = mysql_fetch_object ( $query1 ) );
     array_pop ( $results1 );
    //----------Final Combo 2-------------------------------------------------------------------------
?>

<br/>
Despesa (H):
<select name="sb_dsg">
<?php 
     //----------Intend to present Combo 2 configured--------------------
     foreach ( $results1 as $option ) : ?>
          <option value="<?php echo $option->sb_dsg; ?>"><?php echo $option->descricao; ?></option>
<?php 
     endforeach; 
?>
</select> 

Open in new window


What must be done ?

Thanks in advance!
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Jagadishwor Dulal
Jagadishwor Dulal
Flag of Nepal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Eduardo Fuerte

ASKER

Ok, I'm seeking...
Thanks for your assistance, again....
I was miles away from solution before it...
I'm new in PHP and getting more proficiency with your replies!
jQuery (client side JavaScript) intersects PHP (server side script) in the AJAX technology.  You might find this article interesting.
https://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/A_10712-The-Hello-World-Exercise-with-jQuery-and-PHP.html

Thanks for the points, ~Ray