开发者

How to create simple tree menu using PHP or HTML but without JS?

I want to create simple tree menu. But I can on开发者_如何学Pythonly use PHP or HTML. In my case I am not allowed to include any JavaScripts.


Stu Nichols at CSS Play would be a good place to start looking at.


IMHO, it's bad form. But you could use the GET method with links to pass values to your PHP file then return the appropriate response to the page.

ie.

<?php
    if(!isset($_GET['link'])){
        $_GET['link'] = ""; // if not set, gets dummy value
    }

    $link = $_GET['link'];

    function showPage($link){
        switch($link){
            case "home":
                echo "<a href='page.php?link=homesub1'>Home Sub Menu 1</a><br>";
                echo "<a href='page.php?link=homesub2'>Home Sub Menu 2</a>";
                break;
            case "other":
                echo "<a href='page.php?link=osub1'>Other Page Sub Menu 1</a><br>";
                echo "<a href='page.php?link=osub2'>Other Page Sub Menu 2</a>";
                break;
        }
    }
?>
<a href="page.php?link=home">HOME</a>
<a href="page.php?link=other">Some Page</a>

<br>
<?php
    if($link != ""){
        showPage($link);
    }
?>

Obviously, a lot of thought has to be put in for the design to work. It's a disaster but it gets the job done.

Note: A better approach to this would be to convince whoever is in-charge to let you use JS/jQuery.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜