doucuo9126 2016-08-31 13:12
浏览 71
已采纳

Html js,php category / subcategory / subsubcategory Web导航

I've been trying to get a tutorial on creating a navigation for html Webpages via javascript or php I keep ending up puzzled.

What I want to achieve is a sort of website navigation on the site where a user can select Category via select box then subcategory gets populated via another select box and when user selects subcategory then subsubcategory gets populated via another select box then have a submit button that goes to the url.

Example: list of countries each with own unique html page. So if user hits submit he goes to the page obut if not then user can select state if state is selected then he goes to state unique html page and if not then he selects city then he can navigate to cities unique html page. So the structure looks like this:

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

Any help or advice would be highly appreciated.

  • 写回答

1条回答 默认 最新

  • duanhe1965 2016-08-31 16:11
    关注

    Lets assume you have this html page.

    <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>
    

    now process.php could be something like

    <?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}
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line