Skip to content

Commit

Permalink
gw-prevent-duplicate-drop-down-selections.js: Added "Evolved" message.
Browse files Browse the repository at this point in the history
  • Loading branch information
spivurno authored Aug 29, 2023
1 parent b970d7a commit 7ebb812
Showing 1 changed file with 3 additions and 41 deletions.
44 changes: 3 additions & 41 deletions experimental/gw-prevent-duplicate-drop-down-selections.js
Original file line number Diff line number Diff line change
@@ -1,43 +1,5 @@
/**
* Gravity Wiz // Gravity Forms // Disable Selected Dropdown Choice in Other Dropdown Fields
* https://gravitywiz.com/
*
* Disable a selected dropdown choice in other dropdown fields that have the same set of choices.
*
* Instructions:
*
* 1. Install this snippet with our free Custom JavaScript plugin.
* https://gravitywiz.com/gravity-forms-custom-javascript/
*
* 2. Add the `gfield_ddselect` designator to all the dropdown fields' CSS Class Name setting.
* This snippet has evolved! 🦄
* Find the new version of this snippet here:
* https://github.com/gravitywiz/snippet-library/blob/master/gravity-forms/gw-prevent-duplicate-selections.js
*/
jQuery(".gfield_ddselect").change(function () {
var select_num = jQuery(".gfield_ddselect").length;
var ddvalue = [];
var selected = jQuery("option:selected", jQuery(this)).val();
jQuery(".gfield_ddselect").each(function (i) {
ddvalue[i] = jQuery("option:selected", jQuery(this)).val();
i += 1;
});
var thisID = jQuery(this).attr("id");
jQuery(".gfield_ddselect").each(function (a) {
var parent_el = jQuery(this);
jQuery("option", jQuery(this)).each(function (b) {
// With GP Inventory, any Inventory Exhausted choice should remain disabled.
if (! $(this).hasClass('gpi-disabled')) {
jQuery(this).prop("disabled", false);
}
if (b != 0) {
for (c = 0; c < select_num; c++) {
if (a != c) {
if (ddvalue[c] != '') {
jQuery("option[value='" + ddvalue[c] + "']", parent_el).attr("disabled", true);
}
}
}
}
b += 1;
});
a += 1;
});
});

0 comments on commit 7ebb812

Please sign in to comment.