Put time to drop down box

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ghjk
    Contributor
    • Jan 2008
    • 250

    Put time to drop down box

    I want user to select time from the drop down list. Currently I hard coded the time.
    Ex:
    Code:
    <option value="0" selected="selected"> Select</option>
                   <option value="08:30" >08:30</option>
                   <option value="09:30" >09:30</option>
                   <option value="10:30" >10:30</option>
                   <option value="11:30" >11:30</option>
                   <option value="12:30" >12:30</option>
                   ........
    Is there any better way to do this?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    that depends upon how you get/select the values. probably a good point to look for are the strtotime() and date() functions.

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      Originally posted by ghjk
      I want user to select time from the drop down list. Currently I hard coded the time.
      Ex:
      Code:
      <option value="0" selected="selected"> Select</option>
                     <option value="08:30" >08:30</option>
                     <option value="09:30" >09:30</option>
                     <option value="10:30" >10:30</option>
                     <option value="11:30" >11:30</option>
                     <option value="12:30" >12:30</option>
                     ........
      Is there any better way to do this?
      You mean, is there a more efficient way to do this? What are the time ranges? You could simply loop through the times.

      Comment

      • TheServant
        Recognized Expert Top Contributor
        • Feb 2008
        • 1168

        #4
        W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.


        Yeah, as Markus said, just loop an echo which outputs options, incrementing by 1 or something every pass.

        Comment

        Working...