Copy Exhausted Choices to Another Field

Experimental Snippet 🧪

Instructions

  1. Install this snippet with our free Custom JavaScript plugin. https://gravitywiz.com/gravity-forms-code-chest/
  2. Configure the snippet per the inline instructions.

Code

Filename: gpi-copy-exhausted-inventory-to-another-field.js

/**
 * Gravity Perks // Inventory // Copy Exhausted Choices to Another Field
 * https://gravitywiz.com/documentation/gravity-forms-inventory/
 *
 * Experimental Snippet 🧪
 *
 * Instructions:
 *
 * 1. Install this snippet with our free Custom JavaScript plugin.
 *    https://gravitywiz.com/gravity-forms-code-chest/
 * 2. Configure the snippet per the inline instructions.
 */
// Update "1" to the ID of your Inventory-enabled field.
var $disabled = $( '#input_GFFORMID_1 option:disabled' );

// Update "2" to the ID of the field to which exhausted choices should be copied.
$( '#input_GFFORMID_2' ).html( $disabled.clone().prop( 'disabled', false ) );

$disabled.remove();

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.