如何通过禁用的文本框保存数据? [英] how to save data by disabled text box?

查看:65
本文介绍了如何通过禁用的文本框保存数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

In my jsp page, 1 checkbox, 2 textbox and 1 submit button. The checkbox is used for enabling and disabling the text box. Data saved when textbox is enable but not saved when textbox is disable.

以下代码用于切换.

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

请帮助我.

推荐答案

您可以使用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);
    }       
}

这篇关于如何通过禁用的文本框保存数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆