-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gw-prevent-duplicate-drop-down-selections.js
: Added "Evolved" message.
- Loading branch information
Showing
1 changed file
with
3 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}); | ||
}); |