View Single Post
Join Date: Aug 2008
Posts: 954
Reputation: essential will become famous soon enough essential will become famous soon enough 
Solved Threads: 131
Featured Poster
essential's Avatar
essential essential is offline Offline
Posting Shark

Re: Counter for selectbox

 
0
  #2
Aug 27th, 2008
Please feel free to modify this code to match your needs. If you have any question regarding this code you can document.write('Me on my inbox'). lol! Have a good day...
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Some Title</titles>
  1. <script type="text/javascript">
  2. <!-- BEGIN HIDING
  3.  
  4. /* A simple counter script that will generate each the user select any option in the comboBox! */
  5.  
  6. var i = 0;
  7. var x = 0;
  8.  
  9. function _selected()
  10. {
  11. if ( form1.myselect.options[0].selected ) { i = i + 1;
  12. form1.myselect.options[0].text = 'Count ' + i; }
  13. if ( form1.myselect.options[1].selected ) { x = x + 1;
  14. form1.myselect.options[1].text = 'Count ' + x; }
  15. if ( i == 5 || x == 5 ) { alert('\nThat\'s enough for now');
  16. i = ( i == 5 ) ? 0 : i;
  17. x = ( x == 5 ) ? 0 : x;
  18. }
  19. }
  20. // DONE HIDING -->
  21. </script>
  1. </head>
  2. <body>
  3.  
  4. <form name="form1" action="#" onsubmit="return false;">
  5. <select id="myselect" onchange="_selected();">
  6. <option value="">selection1</option>
  7. <option value="">selection2</option>
  8. </select>
  9. </form>
  10. </body>
  11. </html>
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
Reply With Quote