应禁用表单字段,但单击按钮时,应启用表单字段和列,

时间:2014-02-12 17:04:01

标签: javascript php jquery html

应该禁用行和列的表单字段,但是当单击按钮时,应该启用表单字段,我有11行和11列。我将使用少量行和列指定我的代码。如果有人帮我清楚的话会很高兴...在此先感谢..

<table class="auto-style15" style="width: 100%; height: 100%;">
<tr>
<td class="auto-style11" rowspan="2" style="width: 70px"><strong>Operation No</strong></td>
<td class="auto-style22" rowspan="2" style="width: 156px"><strong>Fixture No</strong></td>

<tr>
<td class="auto-style7" style="width: 70px; height: 25px">
<input name="oprno1" type="text" style="width: 70px" /></td>
<td class="auto-style7" style="height: 25px; width: 156px">
<input name="fixno1" style="width: 150px" type="text" /></td>

<input name="Button1" type="button" value="EDIT" class="auto-style12" />

2 个答案:

答案 0 :(得分:0)

我不知道你的意思,但这可以帮助你:

的jQuery

$('.auto-style12').click(function(){ // . is the class selector # for ids
    $(input).removeAttr('disabled');
}

然后您只需将disabled添加到每个input

答案 1 :(得分:0)

在表格中添加'hasInputs'类,并为您的按钮添加ID。然后,只需在页面加载时禁用表格内的所有输入字段即可:

$(document).ready(function() {
   $('.hasInputs').find('input').prop('disabled', true); 
});

并点击启用它们。

$('#btnEdit').on('click', function() {
   $('.hasInputs').find('input').prop('disabled', false); 
});

Here is a working fiddle.

此外,here is a version还有一个用于切换字段的附加取消按钮。您可以使用类似的方法添加“保存”按钮。