Problem with jQuery slider - time

Posted by Dawid on Stack Overflow See other posts from Stack Overflow or by Dawid
Published on 2010-12-28T19:14:03Z Indexed on 2010/12/28 19:53 UTC
Read the original article Hit count: 251

Filed under:
|
|
|
|

Hello. I'd like to make a slider to choose time(from 1:00 to 4:00) but it doesn't work. It doesn't communicate with 'select'. Can anyone help me?

 <script> 
    $(function() {
        var select = $( "#czastrwania" );
        var slider = $( "<div id='slider'></div>" ).insertAfter( select ).slider({
        min: 60,
        max: 240,
        step: 30,
        range: "min",
value: select[ 0 ].selectedIndex + 1,
            slide: function( e, ui ) {
              var hours = Math.floor(ui.value / 60);
            var minutes = ui.value - (hours * 60);

            if(hours.length == 1) hours = '0' + hours;
            if(minutes.length == 1) minutes = '0' + minutes;
            select[ 0 ].selectedIndex = ui.value - 1;
            }
        });
        $( "#czastrwania" ).change(function() {
            slider.slider( "value", this.selectedIndex + 1 );
        });
    });
    </script>
<select id="czastrwania" name="czastrwania">
 <option value="1:00">1:00</option>
    <option value="1:30">1:30</option>
    <option value="2:00">2:00</option>
    <option value="2:30">2:30</option>
    <option value="3:00">3:00</option>
    <option value="3:30">3:30</option>
    <option value="4:00">4:00</option>  
    </select>

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery