<?php
// print the js code

$sel_num 3// number of select menu to print (and hide)
echo js_multiple_select"dropme""dropme"$sel_num);

// print the first select, without hiding it.
echo my_select("myname1""null""dropme2()")."<br /><br />";

// print the select code and the appropriate div
for ($y=2$y<($sel_num 1); $y++) {
    
$z $y 1;  // used to define the function to call to show the next select
    
echo '<div id="dropme'.$y.'" class="dropcontent">';
    echo 
my_select("myname".$y"null""dropme".$z."()");
    echo 
'</div><br />';
}

function 
my_select($name$default "null"$onchange="") {
    
$str '<select name="'.$name.'" onchange="'.$onchange.'">';
    if (
$default != "null") {
        
$str .= '<option value="'.$default.'">'.$default.'</option>';
    } else {
        
$str .= '<option value="null">&gt;&gt; Choisir une option</option>';
    }
    
$str .= '<option value="null">---</option>
        <option value="a">a</option>
        <option value="b">b</option>
        <option value="c">c</option>
        </select>'
;
    return 
$str;
// my_select

function js_multiple_select$f_name$s_name$number) {
    
// dont forget to open your script tag correctly
    
$str "<script type=\"text/javascript\">
    if (document.getElementById) {
        document.write('<style type=\"text/css\">');
        document.write('.dropcontent{display:none;}');            
        document.write('</style>');
    }"
;

    for (
$i=2$i<($number+1); $i++) {
        
$str .= "
        function "
.$f_name.$i."() {
            if (document.getElementById) {                      
                document.getElementById(\""
.$s_name.$i."\").style.display=\"block\";
            }
        }"
;
        
        }
    return 
$str."
    </script>"
;
}
?>