2011-03-31 48 views
0

我有两套收音机:原型和单选按钮

<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> 

当我点击particip - 不,我需要选择旅行,没有和禁用这两个旅游,是和旅行没有。我试过了:

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

警报出现,但收音机没有变化。任何提示?谢谢。

回答

6

如果你的ID选择你只想$$$

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

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

+0

糟糕,就是这样,谢谢。顺便说一句,分号是可选的JavaScript – xain 2011-03-31 13:20:53

+0

他们是?我以为我知道这门语言! :D – 2011-03-31 13:22:49

+5

它们是可选的,但它们表示语句的结尾,使用它们是明智的。 – Paxwell 2012-11-07 21:15:38