Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 动态下拉菜单_Javascript_Php - Fatal编程技术网

Javascript 动态下拉菜单

Javascript 动态下拉菜单,javascript,php,Javascript,Php,我在我的网站上使用了一组由PHP动态生成的下拉菜单,我在每个页面上使用的这些下拉菜单略有不同,一个页面1我只想显示带有选项的下拉菜单1,并根据选择显示另一个下拉菜单。为了实现这一点,我使用JS,但在开始时,所有三个可能的下拉菜单都会显示出来,但只有一个sopose可见 JS代码: function test(){ //if getElementById('workshop'). exists display none to getElementById('Binary') docume

我在我的网站上使用了一组由PHP动态生成的下拉菜单,我在每个页面上使用的这些下拉菜单略有不同,一个页面1我只想显示带有选项的下拉菜单1,并根据选择显示另一个下拉菜单。为了实现这一点,我使用JS,但在开始时,所有三个可能的下拉菜单都会显示出来,但只有一个sopose可见

JS代码:

function test(){

    //if getElementById('workshop'). exists display none to getElementById('Binary') document.getElementById('Forex').
    if(document.getElementById('workshop')){
        document.getElementById('Forex').style.display = 'none';
        document.getElementById('Binary').style.display = 'none';
    }


    //diSPLAY LOGICS BY document.getElementById('workshop')

    if(document.getElementById('workshop').value == 'Forex'){
        document.getElementById('Forex').style.display = 'inline-block';
        document.getElementById('Forex').name = 'workshop';
    }else{
        document.getElementById('Forex').style.display = 'none';
        document.getElementById('Forex').name = '';
    }

    if(document.getElementById('workshop').value == 'BinaryOptions'){
        document.getElementById('Binary').style.display = 'inline-block';
        document.getElementById('Binary').name = 'workshop';
    }else{
        document.getElementById('Binary').style.display = 'none';
        document.getElementById('Binary').name = '';
    }



}
PHP代码是其中的一部分,给出了一个想法:

function getForex($link){
$timestamp=dateY-m-d

$sql = "SELECT id, course, status, endingDate FROM courses WHERE course LIKE '%Forex%' OR  course LIKE '%forex%' AND status=5";
$query = mysqli_query($link, $sql);
    $option='<select id="Forex" name="workshop">';
    $option.='<option value="">Select Forex Workshop</option>';
    $option.='';
        while($result = mysqli_fetch_assoc($query))
        {
            if($timestamp < $result['endingDate'])
            {
                $option.='<option id="'.$result['id'].'" value='.$result['endingDate'].'>'.$result['course'].$result['endingDate'].'</option>'; 
            }
        }
        $option.='</select>';
        return $option;             
}

所以你只想显示一个下拉列表,对吗?每个下拉菜单的标准是什么?是的,在其中一个页面上,我希望其中一个页面显示选项,并根据这些选项显示另一个下拉菜单,但所有三个可能的菜单都在开始时进行选择