Page 1 of 1

how to open the site selected in dropdown menu?

Posted: Mon Oct 11, 2010 2:33 am
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>

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

Posted: Mon Oct 11, 2010 3:48 am
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

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

Posted: Mon Oct 11, 2010 7:57 am
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