reset drop down

Reply

Join Date: Jul 2006
Posts: 3
Reputation: Lbruce is an unknown quantity at this point 
Solved Threads: 0
Lbruce Lbruce is offline Offline
Newbie Poster

reset drop down

 
0
  #1
Aug 15th, 2006
Hi there,

i have two drop down menus.
what i want to do is when the user chooses an option from the first box, the second box returns to the default (selected) option on change.

Any thoughts are very welcome.
Thanks a lot.
http://www.webdeveloper.com/forum/im...ttons/edit.gif
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 28
Reputation: anuradhu is an unknown quantity at this point 
Solved Threads: 2
anuradhu anuradhu is offline Offline
Light Poster

Re: reset drop down

 
0
  #2
Aug 17th, 2006
check out this ways:

call a function onchange of the first combo
where you will have to set the value of the second combo to the default value.
Say if the default value of the second combo is "default_value"
and the name of the function called on change of the first combo is fnOnChangeFirstCombo and the name of the second combo is SecCombo, then use the following code:
[code]
function fnOnChangeFirstCombo()
{
document.frmName.SecCombo.value="default_value";
}
[code]
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 1,181
Reputation: hollystyles will become famous soon enough hollystyles will become famous soon enough 
Solved Threads: 67
hollystyles's Avatar
hollystyles hollystyles is offline Offline
Veteran Poster

Re: reset drop down

 
0
  #3
Aug 17th, 2006
HTML and CSS Syntax (Toggle Plain Text)
  1. document.frmName.SecCombo.value="default_value";
The above Is not standard or cross browser, you should use getElementById (elementid)
HTML and CSS Syntax (Toggle Plain Text)
  1. var combo = document.getElementById("combo2");



HTML and CSS Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" >
  3. <head>
  4. <title>Combo change</title>
  5. <script type="text/javascript">
  6. function combo2_OnChange()
  7. {
  8. var combo = document.getElementById("combo2");
  9. combo.value = "0";
  10. }
  11. </script>
  12. <style type="text/css">
  13. body
  14. {
  15. font-family: verdana;
  16. }
  17. #fieldset1
  18. {
  19. padding: 15px; text-align: center; width: 150px;
  20. }
  21. #combo1
  22. {
  23. font-weight: bold;
  24. color: red;
  25. }
  26. #combo2
  27. {
  28. color: green;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <fieldset id="fieldset1">
  34. <legend>Choose options</legend>
  35. <br />
  36. <select id="combo1" onchange="combo2_OnChange();">
  37. <option selected="selected" value="0">Option 1</option>
  38. <option value="1">Option 2</option>
  39. </select>
  40. <hr />
  41. <select id="combo2">
  42. <option selected="selected" value="0">Default</option>
  43. <option value="1">First</option>
  44. <option value="2">Second</option>
  45. <option value="3">Third</option>
  46. </select>
  47. </fieldset>
  48.  
  49. </body>
  50. </html>
Last edited by hollystyles; Aug 17th, 2006 at 4:36 pm.
==========================================
Yadda yadda yadda...
Web junky, fevered monkey
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the HTML and CSS Forum


Views: 6324 | Replies: 2
Thread Tools Search this Thread



Tag cloud for HTML and CSS
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC