I want to add a button to the column when clicked would set all other dropdown items on the current page to the selection made.
<select class="select2 select2-offscreen" id="id[0]" name="id[0]">
<option value="not received">Not Received</option>
<option value="received">Received</option>
</select>
<select class="select2 select2-offscreen" id="id[1]" name="id[1]">
<option value="not received">Not Received</option>
<option value="received">Received</option>
</select>
<select class="select2 select2-offscreen" id="id[2]" name="id[2]">
<option value="not received">Not Received</option>
<option value="received">Received</option>
</select>
<button class="go-btn" type="submit">Update All</button>
JS:
$('.go-btn').click(function() {
$("select option").each(function() {
//how to update the dropdow?
});
});
Is this what you are looking for? https://jsfiddle.net/zmbagh9h/3/
var lastSelectedValue = 'not received';
$('select').change(function() {
lastSelectedValue = this.value;
});
$('.go-btn').click(function() {
$('select').val(lastSelectedValue);
});
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.