JavaScript implementation of a set time validity, the sense of the implementation of their own jquery code is too concise, this is a colleague to write a section of JS code, their own research to learn a bit
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> Untitled Document </title>
<style type= "Text/css" >
#lastdate {color: #FF9900; font-style:normal;}
</style>
<body>
<div class= "F-c" >
<select id= "Date_sel" name= "period" class= "Buyconqc select150" >
<option value= "0" > One day </option>
<option value= "1" > Within two days </option>
<option value= "2" > Three days </option>
<option value= "3" > Four days </option>
</select>
<span class= "Postaction" > After <em id= "Lastdate" >2012-9-28</em>, will expire </span>
</div>
<script type= "Text/javascript" >
document.getElementById (' Date_sel '). onchange = function () {
var time = new Date ();
var pre_year = Time.getfullyear ();
var pre_month = Time.getmonth ();
var pre_day = Time.getdate ();
var sel_day = parseint (document.getElementById (' Date_sel '). Value);
Switch (sel_day) {
Case 0:pre_day +=1;break;
Case 1:pre_day +=2;break;
Case 2:pre_day +=3;break;
Case 3:pre_day +=4;break;
Default:pre_day +=1;break;
}
var endtime = new Date (pre_year, Pre_month, Pre_day);
document.getElementById (' Lastdate '). InnerHTML = Endtime.getfullyear () + "-" + (Endtime.getmonth () +1) + "-" + Endtime.getdate ();
};
</script>
</body>