我有一个多行表,每一行都有一个下拉列表。我是 javascript 新手,无法从行中检索所选值。知道怎么做吗?提前致谢。
代码:
function chng_page(serialNum, rowid)
{
alert(rowid);
alert(serialNum);
var select_index = document.getElementById('orderStatus').selectedIndex;
//get the value of selected option
var option_value = document.getElementById('orderStatus').options[select_index].value;
//redirect with value as a url parameter
window.location = 'orderStatus.php?serialNum=' + serialNum + '&status=' + option_value;
}
</script>
//下拉列表代码
<select id="orderStatus" name="orderStatus" onchange="chng_page(<?php echo $serialNum? >, this.parentNode.parentNode.rowIndex)">
<option value="Pending" <?php echo ($status == "Pending") ? ' selected="selected"' : ''; ?>>Pending</option>
<option value="Cooking" <?php echo ($status == "Cooking") ? ' selected="selected"' : ''; ?>>Cooking</option>
<option value="On The Way" <?php echo ($status == "On The Way") ? ' selected="selected"' : ''; ?>>On The Way</option>
<option value="Delivered" <?php echo ($status == "Delivered") ? ' selected="selected"' : ''; ?>>Delivered</option>
</select>