How to auto select current month from drop down on page load when ever the user vists the page at any time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aousaja
    New Member
    • Mar 2022
    • 1

    How to auto select current month from drop down on page load when ever the user vists the page at any time

    I have this drop down and I want to auto select the drop down value to current month as the user gets to this page every time, can anyone help me in this regards I am new to java script please let me know as soon as possible

    Code:
    <select class="customSelect1 floating" id="month" name="month">
                        <option value="1">Jan</option>
                        <option value="2">Feb</option>
                        <option value="3">Mar</option>
                        <option value="4">Apr</option>
                        <option value="5">May</option>
                        <option value="6">Jun</option>
                        <option value="7">Jul</option>
                        <option value="8">Aug</option>
                        <option value="9">Sep</option>
                        <option value="10">Oct</option>
                        <option value="11">Nov</option>
                        <option value="12">Dec</option>
                    </select>
    Last edited by zmbd; Apr 26 '22, 12:12 AM. Reason: [Z{Deleted IMG link as it pointed to OP's local drive}]
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    Use the JavaScript Date object to get the current month and set the dropdown's value accordingly.

    Comment

    Working...