关系管理系统:js代码生成select的出生日期
生活随笔
收集整理的這篇文章主要介紹了
关系管理系统: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 = birthdaydocument.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);}
?
轉載于:https://www.cnblogs.com/lichone2010/p/3178649.html
總結
以上是生活随笔為你收集整理的关系管理系统:js代码生成select的出生日期的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 有船吗船来了是什么歌啊?
- 下一篇: Linux 终端命令行提示符的艺术--P