开发者

Converting standard time to military time widget

I'm trying to create a widget that will create a military time string from a series of dropdowns. I'm using it to create a开发者_C百科n interface for users of a website that need to put in events using standard time but the calendar widget needs military time.

I've got a start but can't seem to figure it out. The code is on jsFiddle. http://jsfiddle.net/Jwp64/

Might be easier to see it there. I've got the function there, just can't seem to get it to apply to text field.

Thanks in advance for any help!


I updated your fiddle, there were some things that were not right: try it here http://jsfiddle.net/Jwp64/7/


http://jsfiddle.net/waitinforatrain/Jwp64/6/

Here is a more verbose form of what is in the fiddle:

$('.foo').click(function(){
    var ampm = $("#open-times-ampm").val();
    var hour = $("#open-times-hour").val();
    var minute = $("#open-times-minute").val();
    var milTime = convertToMilitaryTime(ampm,hour,minute);

    $('#open-time').val( milTime );

    return false;
});

Also, when using jsFiddle, you don't need <script> tags in the Javascript section, and select jQuery in the dropdown on the left.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜