Dropdown list displays url in different frame html-php

1.1k Views Asked by At

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

1

There are 1 best solutions below

0
On

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