Solved

jQuery if select option from parent list, auto populate the child list

Posted on 2014-02-11
5
791 Views
Last Modified: 2014-02-11
Hi,

I need help.

I have Driver Type table

DriverTypeID        Driver    Status       Date
3                  Benefit        1      2014-02-10 00:00:00.000
4                  Billing         1      2014-02-10 00:00:00.000
5                  Blue Card      1      2014-02-10 00:00:00.000
6                  Education      1      2014-02-10 00:00:00.000
7                  Email      1      2014-02-10 00:00:00.000
8                  Group Wide Change      1      2014-02-10 00:00:00.000
9                  ID Card      1      2014-02-10 00:00:00.000
10                   Legal      1      2014-02-10 00:00:00.000
12                  Mailing      1      2014-02-10 00:00:00.000
13                  Media      1      2014-02-10 00:00:00.000
14                  Medical policy      1      2014-02-10 00:00:00.000
15                  New Process      1      2014-02-10 00:00:00.000
16                  Open Enrollment      1      2014-02-10 00:00:00.000
17                  Reform      1      2014-02-10 00:00:00.000


I have DriverSubType table

SubID     DriverTypeID     SubType   Status       Date
1      1                 Hearing      1      2014-02-03 00:00:00.000
2      1                 Medical      1      2014-02-03 00:00:00.000
3      1                 Pharmacy      1      2014-02-03 00:00:00.000
4      1                 Vision      1      2014-02-03 00:00:00.000
5      10                BCBSM      1      2014-02-03 00:00:00.000
6      10                Employer Group      1      2014-02-03 00:00:00.000
7      10                Pharmacy      1      2014-02-03 00:00:00.000
8      10                Provider      1      2014-02-03 00:00:00.000


______________________________________________________________________________

  <SELECT name="SelectDriverType" id="SelectDriverType" style="width:200px;">
             <OPTION>Select ...</OPTION>      
           <cfoutput query="QDriverType">
                  <OPTION value="#QDriverType.DriverTypeID#">#QDriverType.Driver#</OPTION>
                   </cfoutput>
            </SELECT>    

<select id="SelectDriverSubType" name="SelectDriverSubType"  style="width:200px;">
                  </select>  



I need an example of how to populate SelectDriverSubType when user select SelectDriverType

Thanks,
Lulu
____________________________________________________________________
0
Comment
Question by:lulu50
  • 3
  • 2
5 Comments
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39850781
I use jquery chained http://www.appelsiini.net/projects/chained
In their sample, notice the ID of the first series matches the class of the 2nd.
<select id="mark" name="mark">
  <option value="">--</option>
  <option value="bmw">BMW</option>
  <option value="audi">Audi</option>
</select>
<select id="series" name="series">
  <option value="">--</option>
  <option value="series-3" class="bmw">3 series</option>
  <option value="series-5" class="bmw">5 series</option>
  <option value="series-6" class="bmw">6 series</option>
  <option value="a3" class="audi">A3</option>
  <option value="a4" class="audi">A4</option>
  <option value="a5" class="audi">A5</option>
</select>

Open in new window

0
 

Author Comment

by:lulu50
ID: 39850856
Scott,

where would I get these files?

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="jquery.chained.min.js"></script>
0
 

Author Comment

by:lulu50
ID: 39850914
I got it thank you
0
 

Author Closing Comment

by:lulu50
ID: 39850915
Thanks
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39851096
Sorry, feeding break. Glad you figured it out.
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

813 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now