首先在form中用隐藏域定义,如:<input type="hidden" name="birthday" value="${myFrom.birthday}">
在脚本中:
//保存
function save(){
var year = document.myFrom.year.value;
var month = document.myFrom.month.value;
var day = document.myFrom.day.value;
document.myFrom.birthday.value=year+"-"+month+"-"+day;
}
//定义数组
function blankArray(n){
for(var i=0; i<n; i++){
this[i]=null;
this.length=n;
}
}
//在body的onload()方法中加载
function loadData(){
var csrqsj = document.myFrom.birthday.value;
var birthdayTemp= new blankArray(3);
cssj = birthdayTemp.split("-");
$("year").value=cssj[0];
$("month").value=cssj[1];
$("day").value=cssj[2];
}