| | |
Counter for selectbox
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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...
html Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Some Title</titles>
javascript Syntax (Toggle Plain Text)
<script type="text/javascript"> <!-- BEGIN HIDING /* A simple counter script that will generate each the user select any option in the comboBox! */ var i = 0; var x = 0; function _selected() { if ( form1.myselect.options[0].selected ) { i = i + 1; form1.myselect.options[0].text = 'Count ' + i; } if ( form1.myselect.options[1].selected ) { x = x + 1; form1.myselect.options[1].text = 'Count ' + x; } if ( i == 5 || x == 5 ) { alert('\nThat\'s enough for now'); i = ( i == 5 ) ? 0 : i; x = ( x == 5 ) ? 0 : x; } } // DONE HIDING --> </script>
html Syntax (Toggle Plain Text)
</head> <body> <form name="form1" action="#" onsubmit="return false;"> <select id="myselect" onchange="_selected();"> <option value="">selection1</option> <option value="">selection2</option> </select> </form> </body> </html>
Dev.Opera — FOLLOW THE STANDARDS, BREAK THE RULES...
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: horizontal menu
- Next Thread: displaying image at loading time & display message in success after any operation
| Thread Tools | Search this Thread |
ajax ajaxexample ajaxjspservlets array browser bug captcha captchaformproblem cart checkbox child class close codes cookies createrange() cursor date debugger dependent disablefirebug dom dropdown editor element embed engine enter events explorer ext file firefox form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe images internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl maps marquee masterpage math matrixcaptcha media menu object onerror onmouseoutdivproblem onreadystatechange parent paypal pdf php position post programming progressbar prototype rated redirect runtime safari scale scriptlets scroll search security session shopping size software star stars synchronous toggle unicode variables web webservice wysiwyg \n





