Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.