Skip to main content
Inspiring
October 21, 2008
Answered

Drop Down List

  • October 21, 2008
  • 3 replies
  • 752 views
I have categories stored in my database and being access by my drop down list. My question is how will I view the sub categories stored in my database in the next page just by clicking the category in the drop down list without using a button? Thanks in advance!!!!
This topic has been closed for replies.
Correct answer Newsgroup_User
without a button, you will have to do it with javascript.
the simplest thing is to add an onChange event to your select element
which will relocate the user to the next page, passing selected value as
url variable:

<select name="myselect"
onChange="window.location.href='nextpage.cfm?cat='+this.value;">

the above will take the user to nextpage.cfm?cat=[value of selected
option]. so on the nextpage.cfm query your db to get the subcategories
that belong to #url.cat# category.

there are other, more complicated ways to do it: you may want to google
"two selects related", which will show you how to populate a second
select element on the same page based on selection in the first select
element.

hth

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

3 replies

Inspiring
October 21, 2008
hehe. agreed. but sometimes client's requirements are requirements.
but i would probably still place a button next to the select as well...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Inspiring
October 21, 2008
Make sure you indentify yourself on the page with the form so that any keyboard users can hunt you down and shoot you for building such a user unfreindly app.
Newsgroup_UserCorrect answer
Inspiring
October 21, 2008
without a button, you will have to do it with javascript.
the simplest thing is to add an onChange event to your select element
which will relocate the user to the next page, passing selected value as
url variable:

<select name="myselect"
onChange="window.location.href='nextpage.cfm?cat='+this.value;">

the above will take the user to nextpage.cfm?cat=[value of selected
option]. so on the nextpage.cfm query your db to get the subcategories
that belong to #url.cat# category.

there are other, more complicated ways to do it: you may want to google
"two selects related", which will show you how to populate a second
select element on the same page based on selection in the first select
element.

hth

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/