私の要件は、チェックボックスをクリックして保存/更新テキストボックスを無効にし、チェックボックスをオフにして保存/更新する必要があります。チェックの間にlatest_file
の値は1
でなければならず、チェックしていない間はその値は0
でなければなりません。 disableFileName
は、#latestFile
、#fileName
が定義されている質問の戻りでチェックした値がチェックされていない場合
function disableFileName() {
var latestFile = $("#latestFile").is(":checked");
if (latestFile) {
$("#fileName").attr("disabled", "disabled");
} else {
$("#fileName").removeAttr("disabled");
}
}
<table>
<tr>
<td>Process the latest file from the feed location </td>
<td>
<s:checkbox property="latestFile" styleId="latestFile" value="1" onclick="disableFileName();" tabindex="5" />
</td>
</tr>
<tr>
<td>File Name</td>
<td nowrap="true">
<s:text property="fileName" styleClass="textbox" styleId="fileName" style="{width:150}" tabindex="6" />
</td>
</tr>
</table>
'prop'を使用してください。 – Tushar
申し訳ありませんが、私はあなたに手を差し伸べました.... :( –
'attr()'の代わりに 'prop()'メソッドを使い、 ' – Tushar