Hai Folks,

The following code is used to create drop down list using for loop in javascript.
The screen shot is the example for time (12 hours formate) drop down.
Using this script you can create Minutes, Seconds,Years,etc... like this
Note: you want to create one menu, you dont want the <select> tags inside of the loop.

  <script language="JavaScript" type="text/javascript">

            // loop to create the list
            TimeHours();
            function TimeHours()
            {
                var TimeHours = 0
                document.write("<select name='TimeHours'>");

                for (var i=1; i <=12; i++)
                {
                    TimeHours++;
                    document.write("<option>" + TimeHours + "</option>");
                }

            }
   </script>


1 comments

  1. Anonymous // October 1, 2013 at 10:15 PM  

    how to convert that using JOptionPane?

Related Posts Plugin for WordPress, Blogger...