简体   繁体   中英

disable dropdownlist value selected and get the next value of dropdown list

enter image description here

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

i need to disable the value of a selected dropdown list and get the next value of the next dropdown list value when the radio button is selected how can i do that? please help

  if (isset($_POST['Submit']))
  {
while ($row=mysql_fetch_array($result)){

echo "<tr>";
echo "<td>" . $row['candidate_name']."</td>";

echo "<td>" .$row['candidate_gender']."</td";

echo "<td>" . $row['candidate_grade']."</td>";

echo "<td>" .$row['candidate_section']."</td";

       Print '<td><img src="date:image/jpeg;base64,' .base64_encode($row['image']).'"height="60 width="75 /></td>';


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

 mysql_free_result($result);
 mysql_close($link);

   }
 else
 // do nothing
 ?>
 <tr>

Not sure if this is what you are trying to achieve. The following has been done using Jquery and I removed intrusive javascript that you were having.

 $('input:radio').each(function() { $(this).on('click', function(e) { $('#position option[value="' + $(this).val() + '"]').prop('selected', true); }); }); 
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> Choose Position <SELECT NAME="position" id="position"> <OPTION VALUE="none">Please select</option> <OPTION VALUE="name1">some value</option> <OPTION VALUE="name2">another value</option> <OPTION VALUE="name3">yet another value</option> </SELECT> <input type='radio' name='vote' value='name1' /> <input type='radio' name='vote' value='name2' /> <input type='radio' name='vote' value='name3' /> <input type="submit" name="Submit" value="See Candidates" /> 

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