How to display data in the pull-up list for half an hour-php Tutorial

Source: Internet
Author: User
For how to display data in the drop-down list for half an hour, I first set a & lt; select & gt; control to display data between AM and am, that is ...... And so on. use JS to achieve better if you can use the my97 control ------ solution --------------- How to make the drop-down list display data for half an hour
Set The widget displays data between AM and am, that is, am, AM, am ...... And so on. use JS to achieve better performance if you can use the my97 control.


------ Solution --------------------
Sometimes it is simple and the most effective method
Let me write something dynamic for you.




Script
// SelObj select object
// Begin start time
// Edn end time
// Step size
Function fn (selObj, begin, end, step ){
Function mm (str ){
Var re = 0;
Str. replace (/(\ d +) :( \ d +)/, function (_, h, m) {re = h * 60 + m * 1 });
Return re;
}
Function fmt (v) {return (v + 100 + ''). slice (1 )}
Var bv = mm (begin), ev = mm (end );
Console.info (bv, ev)
For (I = bv; I <= ev; I + = step ){
Console.info (fmt (I/60> 0) + ':' + fmt (I % 60 ))
Var text = fmt (I/60> 0) + ':' + fmt (I % 60 );
SelObj. options. add (new Option (text, text ))
}
}

Fn (document. getElementById ("sel1"), '1: 00', '2: 30', 30)
Script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.