I have a table with 10 rows added by looping throw a $result from a database query. When the user selects an option from one of the combos, how do I get its value. I have used Javascript but I can only get it to work with the first combo.
COMBO CODE
JAVASCRIPT
COMBO CODE
Code:
echo"<td><select name='status[]' id='combo' onchange='getComboValue()'>"; echo"<option value='' ". (($row['finished']) == 0 ? "selected='selected'":"") . " >Fixture</option>"; echo"<option value='' ". (($row['finished']) == 1 ? "selected='selected'":"") . " >Live</option>"; echo"<option value='' ". (($row['finished']) == 2 ? "selected='selected'":"") . " >Result</option>"; echo"</select></td>";
Code:
function getComboValue()
{
var combo = document.getElementById("combo");
var selectedText = combo.options[combo.selectedIndex].text;
document.getElementById("hiddenStatus").value = selectedText;
}
Comment