Title: Setting value to textfield using jquery
Last modified: June 7, 2021

---

# Setting value to textfield using jquery

 *  Resolved [maheshcreativeskills](https://wordpress.org/support/users/maheshcreativeskills/)
 * (@maheshcreativeskills)
 * [5 years ago](https://wordpress.org/support/topic/setting-value-to-textfield-using-jquery/)
 * Hello support I am trying to update the text field value using jquery. Please
   guide
 * I am trying using below code
 * $( “.rnField_50 .rnTextFieldInput input”).val(‘custom_val’);
 * the value will set to the textfield but after clicked on Add to cart it will 
   get removed. or same if we clicked on text field it will clearred.

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

 *  Plugin Author [EDGARROJAS](https://wordpress.org/support/users/edgarrojas/)
 * (@edgarrojas)
 * [5 years ago](https://wordpress.org/support/topic/setting-value-to-textfield-using-jquery/#post-14530358)
 * Hello!
 * That happens becuase the plugin doesn’t use jquery and the jquery events are 
   only detected by elements usingn jquery, to change the value you need to do it
   using javascript (no jquery), it is kind of verbose but it is actually easy to
   use:
 * var input=document.querySelector(‘.rnField_3 input’)
 * var nativeInputValueSetter = Object.getOwnPropertyDescriptor(window.HTMLInputElement.
   prototype, “value”).set;
    nativeInputValueSetter.call(input, ’22’);
 * var inputEvent = new Event(‘input’, { bubbles: true});
    input.dispatchEvent(inputEvent);
 * All you need to do is change rnfield_3 with the id of your field and 22 with 
   the value that you want to use.
 * Regards!
 *  Thread Starter [maheshcreativeskills](https://wordpress.org/support/users/maheshcreativeskills/)
 * (@maheshcreativeskills)
 * [5 years ago](https://wordpress.org/support/topic/setting-value-to-textfield-using-jquery/#post-14530955)
 * Thanks a lot it has been sorted.
 *  Thread Starter [maheshcreativeskills](https://wordpress.org/support/users/maheshcreativeskills/)
 * (@maheshcreativeskills)
 * [5 years ago](https://wordpress.org/support/topic/setting-value-to-textfield-using-jquery/#post-14530958)
 *     ```
       <div class="rnTextFieldInput ">
       	<div class="rednaoLabel" style="font-weight: bold;">
       		<label>Number of people</label><span class="rnRequiredInd">*</span>
       	</div>
       	<select class="rnInputPrice" placeholder="Please select" style="width: 100%;">
       		<option value="">Please select</option>
       	</select>
       </div>
       ```
   
 * Can we pass the other values comes from api to the selec box dynamically? like
   input field
    -  This reply was modified 5 years ago by [maheshcreativeskills](https://wordpress.org/support/users/maheshcreativeskills/).

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

The topic ‘Setting value to textfield using jquery’ is closed to new replies.

 * ![](https://ps.w.org/additional-product-fields-for-woocommerce/assets/icon-256x256.
   png?rev=3288566)
 * [Extra Product Options Builder for WooCommerce](https://wordpress.org/plugins/additional-product-fields-for-woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/additional-product-fields-for-woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/additional-product-fields-for-woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/additional-product-fields-for-woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/additional-product-fields-for-woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/additional-product-fields-for-woocommerce/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 3 replies
 * 2 participants
 * Last reply from: [maheshcreativeskills](https://wordpress.org/support/users/maheshcreativeskills/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/setting-value-to-textfield-using-jquery/#post-14530958)
 * Status: resolved