Create drop-down list - Javascript | Coding Cluster - using asp.net, c#, mvc 4, iphone, php, ios, javascript, in asp.net mvc 3 & more
 

Create drop-down list - Javascript

Saturday


Create drop-down list using for loop in Javascript


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>


0 comments:

Post a Comment

Share your thoughts here...

 
 
 

RECENT POSTS

Boost

 
Blogger Widgets