1

ラジオボタンの特定の値が選択されていない(チェックされていない)場合は常にテキストフィールドを無効にしたいラジオボタンがあります。道場のラジオボタンを使っています。これを手伝ってくれませんか。

    <dt><label for="Records_Size">Test Run Size</label></dt>
    <dd>
        <input id="Records_All" type="radio" dojoType="dijit.form.RadioButton" name="SourceQuery" checked 
        value="All"></input>
        <label for="Records_All">All input records</label>
    </dd>
    <dt>&nbsp;</dt>
    <dd>
        <span><input id="Records_Query" type="radio" dojoType="dijit.form.RadioButton" name="SourceQuery" 
        value="Query" ></input>
        <label for="Records_Query">Limit input records to:</label></span><span>&nbsp;<input type="text"
        dojoType="dijit.form.TextBox" id="Row_Count" style="width: 25px;" value="10"/></span>
    </dd>

UIのラジオボタン

基本的に、このボタンがフォーカスを失うたびにトリガーされるイベントと、ボタンがフォーカスを取り戻すたびにトリガーされるイベントが必要ですが、処理は両方のイベントで異なります。

4

1 に答える 1

2

このために純粋にクライアント側のアクティビティが必要な場合は、...

<script>
function ManageTextBox(el){
    t=document.getElementById('Row_Count');
    if (el.value=='Query') {t.disabled=false}
       else {t.disabled=true}
    }
</script>

<dt><label for="Records_Size">Test Run Size</label></dt>
<dd>
    <input id="Records_All" type="radio" dojoType="dijit.form.RadioButton" name="SourceQuery" checked
    value="All" onchange="ManageTextBox(this)"></input>
    <label for="Records_All">All input records</label>
</dd>
<dt>&nbsp;</dt>
<dd>
    <span><input id="Records_Query" type="radio" dojoType="dijit.form.RadioButton" name="SourceQuery" 
    value="Query" onchange="ManageTextBox(this)"></input>
    <label for="Records_Query">Limit input records to:</label></span><span>&nbsp;<input type="text"
    dojoType="dijit.form.TextBox" id="Row_Count" style="width: 25px;" value="10"/ disabled></span>
</dd>

onchange各ラジオボタンには属性があり、[すべて]ラジオボタンがオンになっているため、テキストボックスを開始する必要があることに注意してくださいdisabled。ラジオボタンの値を変更すると、ボタンの新しい値に応じてテキストボックスのステータスを変更する関数が呼び出されます。

http://jsfiddle.net/LyStj/

于 2012-04-17T11:21:12.417 に答える