<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>工时</title> </head> <body> <input type="text" size="10" id="start_day"> <span>日</span><br/> <input type="button" value="Get Time" onclick="get_code()"/> <script type="text/javascript"> var myarr=new Array(); myarr=[01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31] var start_day=document.getElementById(start_day); function get_code() { for (var i=start_day;i<31;i++){document.write("time:"+myarr[i]+"<br/>")} } </script> </body> </html>
var i=start_day的意思是,我想从我指定的日期开始,但这个指定的日期是不确定的哪天。
是否可以这么写?
<script type="text/javascript">
var start_days=new Array();
start_days=[01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
function get_code()
{
var start_day=document.getElementById('start_day').value;
for (var i=start_day;i<31;i++){document.write("time:"+start_days[i]+"<br/>")}
}
</script>