Hiding used option as they are selected
Posted: Sun Mar 11, 2012 4:23 pm
I have a list of options boxes that allow a user to select finishing positions after a race in a php/javascript system. There are a list of names with a dropdown box next to them where the user can select a position. I am trying to hide the positions as they are used so that a user cannot select the same position in two boxes. This is the code that produces the dropdown list, and there can be any number of competitors, therefore any number of position selections. When they click on the option box it calls a function remove_options with the id of the <select> that they have changed as an argument.
This code is in a while loop from a database and the variable $j is increased each time to give each select box a different id. There is one blank option so it can be checked whether a select box has been changed.
I have tried writing a javascript function several times but cannot get close to a working function. Any ideas would be helpful.
Thanks, Lewis
This code is in a while loop from a database and the variable $j is increased each time to give each select box a different id. There is one blank option so it can be checked whether a select box has been changed.
Code: Select all
echo "<td><select name='position[$comp_id]' id='pos$j' onclick=".'"'."remove_options('pos$j')".'"'.">";
echo "<option></option>";
for($i=0;$i<$num_of;$i++) {
$pos=$i+1;
echo "<option>$pos</option>";
echo "</select></td>";
}Thanks, Lewis