我发布了一张图片以更好地解释它。如何将值赋给组合框
所以,想象一下我做一个1搜索,然后我做一个第二,或第三,4th..search,我想回到我的老搜索。
我已经有一些代码保存旧的搜索(工作正常)。我唯一的问题是如何将值赋给组合框,以便组合框返回到旧状态。
我怎么开始这样做?
编辑:
$('#combos').on('change', '.combo', function() {
var selectedValue = $(this).val();
if (selectedValue !== '' && $(this).find('option').size() > 2) {
var newComboBox = $(this).clone();
var thisComboBoxIndex = parseInt($(this).attr('data-index'), 10);
var newComboBoxIndex = thisComboBoxIndex + 1;
$('.parentCombo' + thisComboBoxIndex).remove();
newComboBox.attr('data-index', newComboBoxIndex);
newComboBox.attr('id', 'combo' + newComboBoxIndex);
newComboBox.addClass('parentCombo' + thisComboBoxIndex);
newComboBox.find('option[value="' + selectedValue + '"]').remove();
$('#combos').append(newComboBox);
}
});
var check_combo_box_values = $('#combos .combo').map(function()
{
return $('option:selected', this).map(function() {
return parseInt(this.value);
}).get();
}).get();
我们不能编写代码g我们不知道的源代码。 – Cerbrus
你在用什么语言? jquery是否受侵犯? – CR41G14
@ CR41G14:标签:JavaScript/jQuery。 – Cerbrus