繁体   English   中英

返回HTML页面时禁用输入字段

[英]Disabling input field when go back to the HTML page

我有一个HTML输入页面,可以通过选中名为undefined的复选框来禁用输入字段。

当我检查未定义并转到下一页并返回到输入页面时,必须选中该复选框并禁用输入字段。

现在,当我返回输入页面时,该checkbox已选中,但input fielddisabled

以下是我的javascript函数代码和输入页面代码段。 请帮我。

javascript function:

    function disable_input_field(value){    
    var input_field = document.getElementById("person_" + value);     
    if ($("#undefined_" + value).is(":checked")) {       
        input_field.disabled = true;         
        input_field.style.backgroundColor = "#e6e6e6";       
        document.getElementById(value).value = 'undifined';     
    }else{      
        input_field.disabled = false;       
        input_field.style.backgroundColor = "#ffffff";      
        document.getElementById(value).value = '';     
    } 
}

输入页面代码段:

<tr>                     
<td nowrap class="auto-style34" colspan="3" style="height: 40px;">data</td>                         
<td nowrap class="auto-style39" colspan="3">                            
    <input type="text" style="background-color: white;color: black;border-style:solid;height: 25;ime-mode: active;" id="person_data" name="person_data" size="50" value='<?php echo person_data ?>'>                     
    </td>                       
    <td nowrap class="auto-style39" colspan = "3">                      
    <?php if($check_data != ''){ print_r("if");?> 
    <input type="checkbox" checked name="undefined_data" id="undefined_data" onclick="disable_input_field('data')" >undefined 
    <?php }else{ print_r("else");?>                             
    <input type="checkbox" name="undefined_data" id="undefined_data" onclick="disable_input_field('data')" >undefined                       
    <?php }?>
    <input type="hidden" name="data" id="data">
    </td>

回到输入页面时, $check_data不为空。

$(document).ready(function(){

if($("#undefined_" + value).is(":checked")){
        input_field.disabled = true;         
        input_field.style.backgroundColor = "#e6e6e6";       
        document.getElementById(value).value = 'undifined';  
}

});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM