【问题标题】:Dropdown list displays url in different frame html-php下拉列表在不同的框架中显示 url html-php
【发布时间】:2014-11-30 12:05:14
【问题描述】:
我只能使用 html 和 php。
我有一个有 2 个框架的页面。 1 左和 1 主。
在左边我有一个 下拉列表 和一个 提交 按钮。我希望当我按下提交按钮时显示 main.php 中下拉列表选项的 url。
创建 2 个框架的页面。
<!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>
左帧
<!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>
主框架
<!DOCTYPE html>
<html>
<body>
<?php
$ep = $_POST['links'];
echo "$ep"
?>
</body>
</html>
我不能使用 javascript。我知道我的错在 $_POST
【问题讨论】:
标签:
php
html
drop-down-menu
frames
【解决方案1】:
对于您的 PHP,您将不得不使用类似 switch 和 $_get 函数来调用页面。
以下是我的做法。
它不包括如何使用框架来解决它,但它将向您展示如何在 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;
}