Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need to fill dropdown data based on another drop down

Posted on 2009-07-08
3
Medium Priority
?
430 Views
Last Modified: 2012-05-07
What I am looking for is I have two columns of data in a sql database, here is what it looks like:

Table si_item_types
Columns
Item            Type
Monitor            Large CRT
Monitor            LCD 17
Monitor            LCD 19
Monitor            LCD Large
Monitor            Small CRT
PC            Windows 2000
PC            Windows XP
Phone            4621SW
Phone            8410B
Phone            8410D

Table si_item
Columns
Item
Monitor
PC
Phone

What I want to do is have one drop down with Monitor, PC and Phone and if you select Monitor lets says it will display all the items in si_item_types that have the Item Monitor in the second dropdown. Do I need to use Javascript or can I use PHP to do this, can some one point me in the right direction. Thanks
0
Comment
Question by:arraysg2008
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 13

Expert Comment

by:Murali Murugesan
ID: 24810358
I think javascript would do, since i dont know PHP ;-).

Use Onchange  event on the Select box for drop down with Monitor, PC and Phone.

In the Onchange function submit the form with the selected value and query the db using tht and re-populate the other drop down.

<select name="item" OnChange="sendValue(this.value)">

</select>

<script>
 function sendValue(selValue){
  //send it to the action as query param.
}
</script>


-Murali*
0
 
LVL 6

Accepted Solution

by:
coolersport earned 1000 total points
ID: 24810464
There are many similar questions + answers on the net. Please refer to some of them:
- http://www.experts-exchange.com/Programming/Languages/Scripting/AJAX/Q_23687497.html
- http://codestips.com/php-ajax-cascading-dropdown-using-mysql/

As in your case, it requires communication between client and server for fetching data. Therefore, just javascript would not be sufficient to do the job. If you insist, it can be done with just javascript but all data need to be loaded in advance.

See if those examples up there can answer your question.

Cheers,
Tien
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question