如何保存通过禁用文本框中的数据?(how to save data by disabled text

2019-10-29 05:16发布

在我的jsp页面,1个复选框,2文本框和1提交按钮。 该复选框用于启用和禁用的文本框中。 数据保存在文本框被启用,但是当文本框是禁用不保存。

以下代码是用于切换。

function toggleFields(status){
    if (status==false){
        $("#textbox1").removeAttr("disabled");
        $("#textbox2").removeAttr("disabled");
        } 
        else {
        $("#textbox1").attr("disabled", "disabled");
        $("#textbox2").attr("disabled", "disabled");
    }       
}

请帮我在这。

Answer 1:

您可以使用readonly ,而不是disabled

 $("#textbox1").attr("readonly", true);

您的代码会

function toggleFields(status){
    if (status==false){
        $("#textbox1").attr("readonly", false);
        $("#textbox2").attr("readonly", false);
        } 
        else {
        $("#textbox1").attr("readonly", true);
        $("#textbox2").attr("readonly", true);
    }       
}


文章来源: how to save data by disabled text box?