簡體   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