By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,828 Members | 801 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,828 IT Pros & Developers. It's quick & easy.

Select option in website?

P: 1
hi
can anybody help me on <select> option in website
I have multiple option bar with multiple choices i want when i select one choice in one bar it show only related choices on another option bar. all other choices must be hidden
thanks...


Expand|Select|Wrap|Line Numbers
  1.  
  2. <html>
  3. <head>
  4. <title>options</title>
  5.  
  6. </head>
  7. <body>
  8.  
  9. <select>
  10. <option selected="selected" value="1">Make A Choice</option>
  11. <option value="2">Diploma</option>
  12. <option value="2">UG</option>
  13. <option value="2">PG</option>
  14. </select>
  15.  
  16. <select>
  17.  
  18. <option selected="selected" value="1">Make A Choice</option>
  19. <option value="2">BCA</option>
  20. <option value="2">MBA</option>
  21. <option value="2">MSC</option>
  22. <option value="2">BBA</option>
  23. <option value="2">BSC</option>
  24. <option value="2">ENGEENERING</option>
  25. <option value="2">MBBS</option>
  26. </select>
  27.  
  28.  
  29. </body>
  30. </html>
  31.  
  32.  
I want when i select UG from first option only related option like BCA,BBA,BSc only displayed on second option not all the option. and when i select PG only MBA.MSc and so on
Apr 5 '11 #1
Share this Question
Share on Google+
2 Replies


MusoFreak200
P: 96
hey saurabh,

unfortuneatly the only way that i can think of how you can do what you have said is via using some form of dynamic language such as javascript, php, or coldfusion.

maybe you would yield more results if you tried posting this in the javascript / ajax / dhtml section of the forums.

good luck mate
May 11 '11 #2

Ajo Koshy Josep
P: 5
This can be achieved by using JavaScript.

For example just give a function along with the select in first section like

Expand|Select|Wrap|Line Numbers
  1. <select name="optionone" onClick="checkoptiontwo()">
Write the JS like this

Expand|Select|Wrap|Line Numbers
  1.  
  2. function checkoptiontwo()
  3. {
  4. if(document.getElementById("optionone").value==2)
  5. {
  6. document.getElementById("mbbs").disabled=true;
  7. }
  8. }
  9.  
Don't forget to give each option different names(eg: name="mbbs") like bca,mba,etc and also different values. This is not the exact code. But I think you will get an idea.
May 11 '11 #3

Post your reply

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