0

ブラウザの違いが原因である可能性はありません。Chromeでもテストしました。私のコードのエラーでしょうか?チェックボックスを押すと、テキストボックスが無効になるはずです。これは今のところありません。私が持っているコードは次のとおりです。ページのセクションの上部にスクリプトを配置しました。

フォーム名 : frmPost

 <script type="text/javascript">
      function enabledisable() {
                if (document.getElementById("ePrice").checked) {    
                    document.frmPost.txtPrice.disabled=false;
                } else {
                    document.frmPost.txtPrice.disabled=true;
                }
            }​
    </script>

<input type="text" name="txtPrice" id="txtPrice" size="5">
<input type="checkbox" id="ePrice" name="ePrice"  onclick="enabledisable()"/>
4

2 に答える 2

0
<input type="text" name="txtPrice" id="txtPrice" size="5">
<input type="checkbox" id="ePrice" name="ePrice"/>



$("input[name='ePrice']").click(function() {
    $("input[name='txtPrice']").attr("disabled", this.checked);
 });

私はあなたのために更新を持っていますこれは最新です

http://jsfiddle.net/H8VPY/84/

于 2013-02-06T21:59:43.547 に答える
0

IE9、Chrome、Firefoxで確認

 <script type="text/javascript">
      function enabledisable() {
                if (document.getElementById("ePrice").checked) {    
                    document.frmPost.txtPrice.disabled=false;
                } else {
                    document.frmPost.txtPrice.disabled=true;
                }
            }
    </script>
<form name="frmPost">
<input type="text" name="txtPrice" id="txtPrice" size="5" disabled="disabled">
<input type="checkbox" id="ePrice" name="ePrice"  onclick="enabledisable()"/>
</form>

大丈夫。フォームの名前が frmPost であることは確かですか? そして、入力txtPriceはデフォルトで無効にする必要があると思います

于 2013-02-06T22:02:04.707 に答える