简体   繁体   中英

Disable radio button with dropdown list

How can i disable radio button when click?

在此处输入图片说明

and the other radio buttons with the same position name.

this is the submit button to get the value in dropdown list

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

And this is for the radio button

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

Assign all radio button with same name . May be "radios" . Now, in javascript get all radio-button using their name and loop through. You need to execute below code OnSubmit .

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM