原型和单选按钮

时间:2011-03-31 13:10:29

标签: prototypejs radio-button

我有两套收音机:

<div class="form-row">
    <div class="field-label">
        <label for="part"><span class="style37">Participated</span></label><p class="aste">*</p>
            <input type="radio" name="particip" id="particip-yes" value="on" checked> Yes
            <input type="radio" name="particip" id="particip-no" value="off">No
     </div>
 </div>
 <div class="form-row">
     <div class="field-label">
         <label for="trav"><span class="style37">Traveled?:</span></label>
             <input type="radio" name="traveled" id="traveled-yes" value="on" checked>Yes
             <input type="radio" name="traveled" id="traveled-no" value="off">No
     </div>
  </div>

当我点击参与号时,我需要选择旅行 - 否和禁用旅行 - 是和旅行号码。我试过了:

  Event.observe('particip-no', 'click', function() {
      $$('travel-no').checked=true
      $$('travel-no').disabled=true
      $$('travel-si').disabled=true
      alert('no travel');});

警报显示,但无线电中没有任何变化。任何提示?感谢。

1 个答案:

答案 0 :(得分:6)

如果您按ID选择,则只需要$而不是$$

  $('travel-no').checked=true;
  $('travel-no').disabled=true;
  $('travel-si').disabled=true;

...假设id是正确的。你错过了分号btw