473,394 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to create Dependent Dropdown List?

aveeva
33
My dropdown :


Expand|Select|Wrap|Line Numbers
  1. <div class="form-group">
  2. <label class="control-label col-sm-2" for="i_have">I have :</label>
  3. <div class="col-sm-10">
  4. <select id="old" class="form-control" placeholder="Select I have" name="i_have">
  5.  
  6. <option value = "select_option">Select Option</option>
  7. <option value = "three_compact">3 Compact</option>
  8. <option value = "three_regular">3 Regular</option>
  9. <option value = "three_triple">3 Triple</option>
  10. <option value = "five_compact">5 Compact</option>
  11. <option value = "five_regular">5 Regular</option>
  12. <option value = "five_triple">5 Triple</option>
  13. <option value = "seven_compact">7 Compact</option>
  14. <option value = "seven_regular">7 Regular</option>
  15. <option value = "seven_triple">7 Triple</option>
  16. <option value = "nine_compact">9 Compact</option>
  17. <option value = "nine_regular">9 Regular</option>
  18. <option value = "nine_triple">9 Triple</option>
  19. </select>
  20. </div>
  21. </div>
  22.  
  23.  
  24.  
  25.  
  26. <div class="form-group">
  27. <label class="control-label col-sm-2" for="i_want">I want :</label>
  28. <div class="col-sm-10">
  29. <select id="new" class="form-control" placeholder="Select I want" name="i_want">
  30.  
  31. <option value = "select_option">Select Option</option>
  32. <option value = "three_compact">3 Compact</option>
  33. <option value = "three_regular">3 Regular</option>
  34. <option value = "three_triple">3 Triple</option>
  35. <option value = "five_compact">5 Compact</option>
  36. <option value = "five_regular">5 Regular</option>
  37. <option value = "five_triple">5 Triple</option>
  38. <option value = "seven_compact">7 Compact</option>
  39. <option value = "seven_regular">7 Regular</option>
  40. <option value = "seven_triple">7 Triple</option>
  41. <option value = "nine_compact">9 Compact</option>
  42. <option value = "nine_regular">9 Regular</option>
  43. <option value = "nine_triple">9 Triple</option>
  44. </select>
  45. </div>
  46. </div>

If the first dropdown "3 Compact " is selected second dropdown should not be able to select "3 Compact" & if first dropdown "5 Regular" is selected second dropdown should not be able to select below values like "3 Compact, 3 Regular, 3 Triple, 5 Compact.

The logic is, if first dropdown value selects like 5, second dropdown value must select above 5 not 4 or 3 or 2 or 1.
May 22 '19 #1
3 1188
Luuk
1,047 Expert 1GB
You should create a piece of javascript which will execute when your first dropdown changes value.

Options in a drop down can be disabled by adding 'disabled':
Expand|Select|Wrap|Line Numbers
  1. <option value = "seven_regular" disabled>7 Regular</option>
May 23 '19 #2
aveeva
33
Could you pls explain in brief, I am learning stage pls.
May 23 '19 #3
Luuk
1,047 Expert 1GB
LOL, I was being 'brief'... (maybe too brief...)

Call javascript when selection changes:
https://bytes.com/topic/javascript/a...t-dropdownlist

Disable options in drop down:
https://bytes.com/topic/javascript/a...options-select

I know both links are about 'javascript', and not about 'PHP', so your learning curve might need a change in direction towards javascript.
May 23 '19 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Joseph Barron | last post by:
Here is a SIMPLE problem that I'm trying to solve. It works in Netscape 6.2, but IE6 gives ""No such interface supported." Below are page1.htm and page2.htm . In page1.htm, there are two...
2
by: Tony Grider | last post by:
I am trying to find a way to create dependent dropdown lists in C# The old way I knew involved javascript and will no longer work in the new design. I need for each list to be database driven (data...
1
by: Larry Rekow | last post by:
Using: MS SQL, VS.Net 2003, VB.Net Each night our SQL db imports two text file reports into two tables: Table 1 has info on various shipments (shipment number, date, destination, etc.) Table 2...
5
by: JIM.H. | last post by:
Hello, I need to create a dropdown list that combines 3 fields form a table and show it a single item in dropdownlist. So List should have rows like Filed1-Filed2-Filed3. How can I do this?...
2
by: computer_angel | last post by:
can someone help me pls.... how to get the value from the mysql when using two drop down that is dependent to the first? For example....(online enrolment) department then the other dropdown...
2
by: Travis | last post by:
Hi , I use C# to create a dropdown list in the web page and I place some code in the SelectedIndexChanged event. But when I click on the list to select certain job to perfom , there is not...
2
by: doc1355 | last post by:
Hi, I have two dynamic drop down lists: State and City. What I'm trying to do is first I need the city list to be empty on load. Then after a visitors selects the "state" from the first list, the...
3
by: fish919 | last post by:
Hello All, I am creating a date base in access. I want to create a dropdown list box that is connected to another dropdown list box. You start with a dropdown list that has 5 choices and each of...
1
by: princebhea | last post by:
How to create a dependent dropdown ,country ,state,city pls send me,suppose ,i click the country it will disply the all country list,when i select the india it will disply the all state list of india...
6
by: Bijiann | last post by:
I am doing a program in java .I have designed a java server page which has 3 drop down list's...country,state.I want to display only corresponding the values in drop down list state when a country is...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.