Jump to content

drop down menu


himani

Recommended Posts

have created a dropdown box by fetching values of categories from mssql database.

so can anybody help me in doing this->

if i select any option from drop down menu it should directly to that particular page and should display all the values under that category.

for eg

if i select category india it should display all the states in india

Himani  ???

Link to comment
https://forums.phpfreaks.com/topic/108650-drop-down-menu/
Share on other sites

Well forget ajax - it's not needed here since you want to go directly to another page. This is a javascript example. The <option value='india' or whatever you want to call it would be the name of the page that contains the states ie: 'india'. The javascript function will add it's ending ie: '.php' or '.html' 

--------------------------------------

<html>

<body>

<?php

 

echo "<form name='formcountries' method='post' action=''>";

echo "<select name='countries' onchange='getstates(this.form)'>";

echo "<option value='india'>India</option>";

echo "<option value='africa'>Africa</option>";

echo "<option value='america'>America</option>";

echo "</select></form>";

 

?>

<script language='javascript'>

 

function getstates(frm){

 

var box = frm.countries;

var value = box.options[box.selectedIndex].value;

window.location.href= eval('"http://www.youraddress.com/' + value + '.php"');

}

</script>

</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/108650-drop-down-menu/#findComment-557451
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.