禁用/启用输入字段

时间:2013-04-16 14:01:37

标签: jscript

使用此示例代码,我尝试启用/禁用字段“arrdatfrom”。但是,一旦此文本字段被禁用,我就无法重新启用它。当用户单击“刷新”按钮时,将执行以下功能。我已经构建了这个小小的演示,以证明我已经尝试了很多方法来做到这一点。有什么想法吗?

function showBooking() {
    var d = new Date()
    formvals.arrdatefrom    = document.getElementById("arrdatfrom").value
    formvals.arrdatethru    = document.getElementById("arrdatthru").value
    formvals.depdatefrom    = document.getElementById("depdatfrom").value
    formvals.depdatethru    = document.getElementById("depdatthru").value
    formvals.bookname       = document.getElementById("bookname").value
    formvals.peakroomfrom   = document.getElementById("peakroomfrom").value
    formvals.peakroomthru   = document.getElementById("peakroomthru").value
    formvals.peakattendfrom = document.getElementById("peakattendfrom").value
    formvals.peakattendthru = document.getElementById("peakattendthru").value

    alert (' ngs.hta  ready to enable')
    document.getElementById("arrdatfrom").enabled = 'true'

    alert ('ngs.hta in showBooking!!  disable.  ')
    document.getElementById("arrdatfrom").disabled = 'true'
    ...

1 个答案:

答案 0 :(得分:0)

没有财产.enabled。要重新启用已禁用的元素,请设置.disabled = false