Hi Everyone,
I'm changing the time by 1 hour in the second selectbox, based on what's selected in the first selectbox.
The code is working perfectly fine, you can paste it in your texteditor and fire it up in your webbrowser to see how it works.
The code is just a bit cluttered. So any (better) suggestions are welcome...
<!DOCTYPE html> <html> <head> <script src="http://code.jquery.com/jquery-latest.js"></script> </head> <body> <select id="mySelect"> <option value="8">08:00</option> <option value="9">09:00</option> <option value="10">10:00</option> </select> <select id="mySelect_2"> <option value="8">08:00</option> <option value="9">09:00</option> <option value="10">10:00</option> </select> <script> $("#mySelect").change(function(){ var selected = $(this).attr("selectedIndex"); var max_select_box = $("#mySelect option").length -1; if (selected == max_select_box) { $("#mySelect2").attr("selectedIndex", selected); } else { $("#mySelect2").attr("selectedIndex", selected + 1); } $("#mySelect_2").change(function(){ var selected = $(this).attr("selectedIndex"); var currently_selected = $("#mySelect").attr("selectedIndex"); if (selected < currently_selected) { $("#mySelect").attr("selectedIndex", selected); } }); }); </script> </body> </html>