JavaScript从隐藏字段检查值并将其设置为隐藏字段值

时间:2012-09-13 14:47:39

标签: javascript

function ClientDate(item) {
        if(item.value == "")
            return false;
        var today = new Date(doc.findItem('stop_date').value);
        var cDate = new Date(item.value);
        var fDate = new Date().setDate(today.getDate()+45);
        //alert("Stop Date is "+fDate.toString());
        //alert("client Date is "+cDate.toString());
        if (cDate < fDate){
            PC.setActivePage(doc.getPage("client"));
            alert("WARNING: date should be at least 45 days from today.");
            item.value = "";
            return false;
        }
        return true

xml代码

<row height="17">
  <text x="1" width="94" height="16" align="left">Corrected by Date:</text>
  <edit x="86" width="70" height="16" id="stop_date5" onchange="fixdate(this,true);" readonly="yes" maxlength="10" />
  <edit type="button" x="158" width="55" height="16" id="calendar_doc_select" align="center" 
   onclick="doc.findItem('stop_date').value=PC.popupCalendar(this.page, 'stop_date');"> Calendar</edit>

我的问题是如何从隐藏的领域填充?例如,如果隐藏字段从9/1/12开始填充45天,则为10/15/12。

隐藏字段ID为'client_date2'

1 个答案:

答案 0 :(得分:0)

获取隐藏字段值:

var hidden_value = document.getElementById('client_date2').getAttribute('value');

设置字段的值:

document.getElementById('client_date2').setAttribute('value',whatever);