Title: passing jQuery custom value
Last modified: December 15, 2018

---

# passing jQuery custom value

 *  [edwardsmark](https://wordpress.org/support/users/edwardsmark/)
 * (@edwardsmark)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/passing-jquery-custom-value/)
 * hello –
 * i am thinking the best way to pass a custom value using jQuery might be something
   like this:
 *     ```
       jQuery("input.asp_product_custom_field_input").val("Marks Custom Value");  
       jQuery(".asp_product_custome_field_input").prop("readonly", true); 
       jQuery("input#asp-custom-field-0").prop("disabled", true); 
       ```
   
 * any opinions?
 * EDIT:
 * this works too:
 * `jQuery("input[name=charge_description]").val('New Value!');`
    -  This topic was modified 7 years, 5 months ago by [edwardsmark](https://wordpress.org/support/users/edwardsmark/).
    -  This topic was modified 7 years, 5 months ago by [edwardsmark](https://wordpress.org/support/users/edwardsmark/).
    -  This topic was modified 7 years, 5 months ago by [edwardsmark](https://wordpress.org/support/users/edwardsmark/).
    -  This topic was modified 7 years, 5 months ago by [edwardsmark](https://wordpress.org/support/users/edwardsmark/).
    -  This topic was modified 7 years, 5 months ago by [edwardsmark](https://wordpress.org/support/users/edwardsmark/).
    -  This topic was modified 7 years, 5 months ago by [edwardsmark](https://wordpress.org/support/users/edwardsmark/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [edwardsmark](https://wordpress.org/support/users/edwardsmark/)
 * (@edwardsmark)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/passing-jquery-custom-value/#post-10999205)
 * this code seems to work fine:
 *     ```
       jQuery( document ).ready( () =>  {
   
         jQuery('div.asp_product_item_top').hide();   // hide the product description
         jQuery('div.asp_product_description').hide();   // hide the product description
         jQuery('label.asp_product_custom_field_label').hide();   // hide the product custom field label
   
         const defaultDescription = jQuery('input[name=charge_description]').val() ;  //establish default
   
         jQuery('input.asp_product_custom_field_input').prop('readonly', true);
   
         jQuery("[name='dropdown-content']").on('change', (eventData, handler) => {
   
             let selectedLanguage = jQuery("[name='dropdown-content'] option:selected").text();
   
             jQuery('input.asp_product_custom_field_input').val(selectedLanguage);
   
             let newTitle
                   = selectedLanguage
               	  +	' -- '
               	  +	defaultDescription
               	  ;
   
             jQuery('input[name=charge_description]').val(newTitle); 
             stripehandler0.data.description = newTitle;
         });
       });
       ```
   
 * i am using “dropdown content” to create a drop down menu, and using “ad inserter”
   to include the jQuery stuff.
    any other suggestions or thoughts?
    -  This reply was modified 7 years, 4 months ago by [edwardsmark](https://wordpress.org/support/users/edwardsmark/).
    -  This reply was modified 7 years, 4 months ago by [edwardsmark](https://wordpress.org/support/users/edwardsmark/).
 *  Plugin Contributor [Alexander C.](https://wordpress.org/support/users/alexanderfoxc/)
 * (@alexanderfoxc)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/passing-jquery-custom-value/#post-11002764)
 * Hi.
 * As I understand, you want the custom value to be changed depending of the dropdown
   select value?
 * You can try to use product variations for your needs, for example: [https://s-plugins.com/creating-variable-products-using-the-stripe-payments-plugin/](https://s-plugins.com/creating-variable-products-using-the-stripe-payments-plugin/)
 * It would create a dropdown for you without any need to use any additional javascript.
 * If you can provide an example of what you’re trying to achieve exactly, I can
   think of some other suggestions 😉
 *  Thread Starter [edwardsmark](https://wordpress.org/support/users/edwardsmark/)
 * (@edwardsmark)
 * [7 years, 4 months ago](https://wordpress.org/support/topic/passing-jquery-custom-value/#post-11004754)
 * i am trying to use a drop-down to pass a custom value. your variable-products
   option looks very useful, but i cannot seem to cause the plugin to either change
   the title in the stripe payment popup nor pass values into stripe itself. in 
   my case, the price is not changing.
 * in other words, our customers will (hopefully) make a $99 purchase. they must
   choose which language they wish to purchase, and they are all the same price.
   the customers’ selected language will be passed to stripe via your ultra-cool
   custom-field option.
 * the short description obviously then just appears on invoices, emails, etc.
 * stripe passes both of these values back during the “callback” – this is extraordinarily
   useful.
 * my jQuery code is modifying the custom-code value:
 *     ```
       let selectedLanguage = jQuery("[name='dropdown-content'] option:selected").text();
       jQuery('input.asp_product_custom_field_input').val(selectedLanguage);
       ```
   
 * the rest of the code is changing the short description:
 *     ```
       let newTitle     = selectedLanguage
               	  +	' -- '
               	  +	defaultDescription
               	  ;
   
       jQuery('input[name=charge_description]').val(newTitle); 
       stripehandler0.data.description = newTitle;
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘passing jQuery custom value’ is closed to new replies.

 * ![](https://ps.w.org/stripe-payments/assets/icon-128x128.png?rev=2705524)
 * [Accept Stripe Payments](https://wordpress.org/plugins/stripe-payments/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/stripe-payments/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/stripe-payments/)
 * [Active Topics](https://wordpress.org/support/plugin/stripe-payments/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/stripe-payments/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/stripe-payments/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [edwardsmark](https://wordpress.org/support/users/edwardsmark/)
 * Last activity: [7 years, 4 months ago](https://wordpress.org/support/topic/passing-jquery-custom-value/#post-11004754)
 * Status: not resolved