how to open the site selected in dropdown menu?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
boneh
Forum Newbie
Posts: 4
Joined: Mon Oct 11, 2010 2:29 am

how to open the site selected in dropdown menu?

Post by boneh »

Hi,
got a question.
If I take for example word in my dropdown menu, and I click the button, I want it to open for example word.htm, if I take Excell in dropdown menu I want to open excell.htm
Can someone help me with showing the code, cause I tried a lot but can't find it..

Tyvm

Code: Select all

<body>
<form method="post" action="<?php echo $PHP_SELF ?>">
<select name ="lessen_id">
<?php
$db = mysql_connect("localhost", "root")
or die ("Kan niet verbinden: " . mysql_error());
mysql_select_db("lessen", $db);
$sql = "SELECT * FROM lessen";
$resultaat = mysql_query($sql); //Voer SQL code uit
while ($rij = mysql_fetch_array($resultaat)) {
echo "<option value =\"";
echo $rij["lessen_id"]. "\">";
echo $rij["naam_lessen"]. "</option>\n";
}
mysql_close($db);
?>
</select>
</form>
<?php
echo "<input type=\"submit\" name=\"artikelnaam\" value=\"More information....\">";
?>
</body>
kalpesh.mahida
Forum Commoner
Posts: 36
Joined: Wed Oct 06, 2010 7:09 am

Re: how to open the site selected in dropdown menu?

Post by kalpesh.mahida »

Hi, I think you need to implement a javascript call to redirect your page to selected option of your drop down menu, bellow is something you are looking for,

<form>
<select name="my_select" id="my_select">
<option value="excel.html">Excel</option>
<option value="word.html">Word</option>
</select>
<input type="button" value="Submit" onclick="submitOption()" />
</form>
<script>
function submitOption() {
var mySelect = document.getElementById('my_select');
location = mySelect.value;
}
</script>

Hope this will help you,
Kalpesh Mahida
boneh
Forum Newbie
Posts: 4
Joined: Mon Oct 11, 2010 2:29 am

Re: how to open the site selected in dropdown menu?

Post by boneh »

kalpesh.mahida wrote:Hi, I think you need to implement a javascript call to redirect your page to selected option of your drop down menu, bellow is something you are looking for,

<form>
<select name="my_select" id="my_select">
<option value="excel.html">Excel</option>
<option value="word.html">Word</option>
</select>
<input type="button" value="Submit" onclick="submitOption()" />
</form>
<script>
function submitOption() {
var mySelect = document.getElementById('my_select');
location = mySelect.value;
}
</script>

Hope this will help you,
Kalpesh Mahida
Tyvm,
this is what I needed ;)

greetz, Boneh
Post Reply