• Resolved maheshcreativeskills

    (@maheshcreativeskills)


    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

    (@edgarrojas)

    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

    (@maheshcreativeskills)

    Thanks a lot it has been sorted.

    Thread Starter maheshcreativeskills

    (@maheshcreativeskills)

    <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

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Setting value to textfield using jquery’ is closed to new replies.