943,897 Members | Top Members by Rank

Ad:
Aug 15th, 2006
0

reset drop down

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Lbruce is offline Offline
3 posts
since Jul 2006
Aug 17th, 2006
0

Re: reset drop down

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]
Reputation Points: 12
Solved Threads: 2
Light Poster
anuradhu is offline Offline
28 posts
since Apr 2006
Aug 17th, 2006
0

Re: reset drop down

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.
Reputation Points: 262
Solved Threads: 68
Veteran Poster
hollystyles is offline Offline
1,181 posts
since Feb 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: CSS For Table
Next Thread in HTML and CSS Forum Timeline: How to generate pdf file automatically at background?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC