Html js,php分类/子分类/子分类网页导航


Html js,php category/subcategory/subsubcategory Web navigation

我一直在尝试通过javascript或php创建html网页导航的教程,但我一直感到困惑。

我想要实现的是在网站上的一种网站导航,用户可以通过选择框选择类别,然后通过另一个选择框填充子类别,当用户选择子类别,然后通过另一个选择框填充子类别,然后有一个提交按钮到url。

示例:国家列表,每个国家都有自己独特的html页面。如果用户点击提交,他会跳转到,如果没有,用户可以选择状态,如果状态被选中,他会跳转到状态唯一的html页面,如果没有,他会选择城市,他会跳转到城市唯一的html页面。结构是这样的

Country/America.html -Country/State/Texas.html -Country/State/city/Texas-city.html

如果有任何帮助或建议,我将不胜感激。

让我们假设你有这个html页面。

<form action="process.php" method="GET">
    <select name="set1">
        <option>Option...1</option>
        <option>Option...2</option>
        <option>Option...n</option>
    </select>
    <select name="set2">
        <option>Option...1</option>
        <option>Option...2</option>
        <option>Option...n</option>
    </select>
    <!-- ... as many as needed -->
    <input type='submit' >
</form>

process。php可以是

<?php
//Start backwards so you know the 
//last question answered
if(isset($_GET['set2'])){
    //Assuming the value is the same name as the html page.
    //If the path differs add the directories needed.
    header('Location: {$_GET['set2']}.html');
    exit;
}
else if(isset($_GET['set1'])){
    header('Location: {$_GET['set1']}.html');
    exit;
}
else {//..What to do when nothing was selected}
?>