2017-09-23 62 views
0

如何在单击时禁用单选按钮?使用下拉列表禁用单选按钮

enter image description here

并用相同的名称的位置的另一单选按钮。

这是提交按钮来获得下拉列表

<form name="fmNames" id="fmNames" method="post" action="vote.php" 
onSubmit="return positionValidate(this)"> 
<tr> 
    <td>Choose Position</td> 
    <td><SELECT NAME="position" id="position" onclick="getPosition(this.value)"> 
     <OPTION VALUE="select">select 
    <?php 
    //loop through all table rows 
    while ($row=mysql_fetch_array($positions)){ 
    echo "<OPTION VALUE=$row[position_name]>$row[position_name]"; 
    //mysql_free_result($positions_retrieved); 
    //mysql_close($link); 
    } 
    ?> 
    </SELECT></td> 
    <td><input type="submit" name="Submit" value="See Candidates" /></td> 
</tr> 
<tr> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
</tr> 
</form> 

的价值,这是单选按钮

if (isset($_POST['Submit'])) 
    { 
echo "<td><input type='radio' name='vote' value='$row[candidate_name]' 
onclick='getVote(this.value)' /></td>"; 
} 
+0

您的意思是说,当单击其中一个单选按钮时,您想要禁用所有单选按钮吗? –

+0

是在无线电的相同位置。你可以帮我吗 ? –

回答

0

分配具有相同名称的所有单选按钮。可能是"radios"。现在,在javascript中获取所有单选按钮的名称并循环播放。您需要执行以下代码OnSubmit

var radios=document.getElementsByName("radios"); 

for (var i=0, iLen=radios.length; i<iLen; i++) { 
    radios[i].disabled = true; 
}