Is there a way to increment time using javascript?

So I am storing times as '01:30:00'. I have a start time and a date time dropdown. I want the dropdown to be set to the start time + 1hr. Is there a way to add the time via javascript or jquery?

Here's my current code:



Try this:

  • find the selected index of the start time
  • bump it up by 2 to find your end time index (given that you've got half hour increments)
  • use the mod operator % to wrap back to index 0 or 1 (for 00:00 and 00:30 respectively)
        var sel =$(this).attr('selectedIndex');
        var endIdx = (sel + 2) % 48; // 47 is 23:30, so 48 should go back to index 0
        $(".end_time").attr('selectedIndex', endIdx);        

Try it out on JSBin.

Need Your Help

How to get response data from servlet inside a div?

javascript html servlets

I have this simple html piece of code, whenever I click on any of the buttons the server will send back some string, I want it to be displayed in #response div.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.