Im using jQuery.
$('#ranges').on('change', '.combo', function() {
var selectedValue = $(this).val();
var s = $(this).parent("div").attr("class");
if ($(this).find('option').size() > 2) {
var newComboBox = $(this).clone();
var thisComboBoxIndex = parseInt($(this).attr('data-index'), 10);
var newComboBoxIndex = thisComboBoxIndex + 1;
$('div.'+s+' .parentCombo' + thisComboBoxIndex).remove();
if (selectedValue !== '') {
newComboBox.attr('data-index', newComboBoxIndex);
newComboBox.attr('id', 'combo' + newComboBoxIndex);
newComboBox.addClass('parentCombo' + thisComboBoxIndex);
newComboBox.find('option[val="' + selectedValue + '"]').remove();
$('div.'+s).append(newComboBox);
}
});
How can I garantee that value before is always higher than next one? May alert user to that issue or turn that combobox_text_value to “red” or prevent user to submit.
At fiddle eg. if I select 2 at first combo I should only select 3 in the next one.
ps: notice me, if you ned more code.
Dynamic combobox handling with values
See working jsfiddle:
http://jsfiddle.net/JaVVe/22/