关系管理系统:js代码生成select的出生日期

//page初始调用
function
pageInit() { makeYear(); makeMonth(); makeDay(); } //产生Year function makeYear(){ var year = document.getElementById("year"); for(var i=1901;i<=new Date().getYear();i++){ var option = document.createElement("option"); option.value = i; option.innerText = i; year.appendChild(option); } } //产生Month function makeMonth() { var month = document.getElementById("month"); for(var i=2;i<=12;i++) { var option = document.createElement("option"); if(i<10) { option.value = '0' + i; option.innerText = '0' + i; }else{ option.value = i; option.innerText = i; } month.appendChild(option); } } //产生day日 function makeDay() { var day = document.getElementById("day"); for(var i=2;i<=31;i++) { var option = document.createElement("option"); if(i<10) { option.value = '0' + i; option.innerText = '0' + i; }else{ option.value = i; option.innerText = i; } day.appendChild(option); } } function dosubmit() { makeBirthday(); makePreference(); return true; } //合成出生日期 function makeBirthday(){ var year = document.getElementById("year").value; var month = document.getElementById("month").value; var day = document.getElementById("day").value; var birthday = year + "-" + month + "-" + day; var input = document.createElement("input"); input.type="hidden"; input.name = "birthday"; input.value = birthday document.getElementById("customer").appendChild(input); } //合成爱好单选项 function makePreference() { var preference = ""; var pres = document.getElementsByName("pre"); for(var i=0;i<pres.length;i++) { if(pres[i].checked==true) { preference = preference + pres[i].value + ","; } } preference = preference.substr(0,preference.length-1); var input = document.createElement("input"); input.type = "hidden"; input.name = "preference"; input.value=preference; document.getElementById("customer").appendChild(input); }

 

posted @ 2013-07-08 20:48  亂舞春秋  阅读(207)  评论(0编辑  收藏  举报