JS dynamically add Select option by system time limit

Source: Internet
Author: User

Although it is a simple effect, or need to accumulate, record a bit;

After August 1, delete the last item and add a new level 2016

— —Level 2015Level 2014Level 2013Level 2012



After June 1, delete the last item and add a new level 2016

— —Level 2016Level 2015Level 2014Level 2013

Source:

 <select id= "Myselect1", 
<option value= "" >--</OPTION>
<option value= "Level 2015" >201 Level 5 </option>
<option value= "Level 2014" >2014 level </option>
<option value= "Level 2013" >2013 level </ Option>
<option value= "Level 2012" >2012 </option>
</select><br><br>

<select id= "Myselect2",
<option value= "" >--</OPTION>
<option value= "Level 2015" >2015 level < ;/option>
<option value= "Level 2014" >2014 </option>
<option value= "Level 2013" >2013 level </option
<option value= "level 2012" >2012 level </option>
</select>

var time = new Date ();

var month=time.getmonth () +1;

var day=time.getday ();
    if (month>5&&day>1) {
var Objselect=document.getelementbyid ("Myselect2");
ObjSelect.options.add (New Option ("Level 2016", "Level 2016"), 1);
ObjSelect.options.remove (5);
}
if (month>7&&day>1) {
var Objselect=document.getelementbyid ("Myselect1");
ObjSelect.options.add (New Option ("Level 2016", "Level 2016"), 1);
ObjSelect.options.remove (5);
}

JS dynamically add Select option by system time limit

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.