duansha8115 2014-11-30 12:05
浏览 25

下拉列表在不同的框架html-php中显示url

I can use only html and php. i have a page with 2 frames. 1 left and 1 main. On the left i have a dropdown list and a submit button.I want when i press submit button to display the url of the option of dropdown list in the main.php.

The page that creates 2 frames.

<!DOCTYPE html>
<html>
    <frameset  cols="25%,*" >
<frame src="left5.php" name="leftFrame" id="leftFrame" title="leftFrame" />
<frame src="main5.php" name="mainFrame" id="mainFrame"  title="mainFrame" />
    </frameset>
</frameset>
<body>
</body>
</html>

LEFT frame

<!DOCTYPE html>
<html>
<body>
<form name="links" action="main5.php" method="post">
<select name="NAME" id="ex_name">
<option value="../url1.html">URL1</option>
<option value="../url2.php">URL2</option>
<option value="../url3.php">URL3</option>
</select><input type="submit" value="GO!" name="submit"/>
</form>
</body>
</html>

Main frame

<!DOCTYPE html>
    <html>
    <body>
    <?php
    $ep = $_POST['links'];
    echo "$ep"
    ?>
    </body>
    </html>

I cant use javascript.I know my fault is in $_POST

</div>
  • 写回答

1条回答 默认 最新

  • dongzhan1878 2014-11-30 13:27
    关注

    For your PHP, you're going to have to use something like switch and $_get functions to call the page.

    Below is how I would do it.

    It does not include how to work it out with frames, but it will show you how to call a local page in PHP.

    index.php

    body {
        margin: 0;
        background-color: red;
    }
    .mymenu {
        position: absolute;
        width: 300px;
        top: 0;
        left: 0;
        background-color: blue;
    }
    .mymenu a {
        color: #FFF;
    }
    .main{
        margin-left: 300px; /* because of .mymenu's width */ 
    }
    <div class="mymenu">
        <a href="index.php?p=whatever1">Link1</a><br />
        <a href="index.php?p=whatever2">Link2</a><br />
        <a href="index.php?p=whatever3">Link3</a>
    </div>
    
    <div class="main">
    <?php 
        include("things.php"); /* open things.php */
    ?>
    </div>

    things.php

    /* get p from URL */
    if (isset($_GET["p"])) { $p = $_GET["p"]; } else { $p = ""; }
    
    function anotherThing(){
        echo "anotherThing page";
    }
    
    function thatThing(){
        echo "thatThing page";
    }
    
    function thisThing(){
        echo "thisThing page";
    }
    
    /* called from e.g. http://yourwebsite.com/index.php?p=whatever2 */
    
    switch($p) {
        case "whatever3":
            anotherThing();
        break;
    
        case "whatever2":
            thatThing();
        break;
        
        case "whatever1":
        default:
            thisThing();
        break;
    }

    </div>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100