gpt4 book ai didi

Javascript/Jquery 方法获取更改事件下拉列表的先前选择值

转载 作者:行者123 更新时间:2023-11-30 16:56:20 25 4
gpt4 key购买 nike

<分区>

我有以下 php 和 javascript 代码片段。

 <td align="center">
<select id = "selectedUnit" class="form-control" onchange="saveToDatabase(this.value,'Unit','<?php echo $ingredientArray[$i][0]; ?>')"><?php
$j=0;
for($j=0;$j<count($unitTypeArray);$j++) { ?>
<option value="<?php echo $unitTypeArray[$j][0]; ?>" <?php if($ingredientArray[$i][4] == $unitTypeArray[$j][0]){ echo 'selected';} ?>><?php echo $unitTypeArray[$j][1]; ?></option><?php
} ?>
</select>
</td>

上面是我的下拉菜单,我想要的是在下拉菜单更改事件中获取之前选择的值,如下所示。

function saveToDatabase(editableObj,column,id) {
//editableObj gives me the currently changing value .
// How I will get the previous selected value ?I am doing it as follows.
var $selected = $(this).find(':selected');
var text = $selected.prev().text(); //previous value
}

请帮我解决这个问题。谢谢。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com