jquery - How to keep original user-entered value intact, while still being able to change it in the input field programmatically -



jquery - How to keep original user-entered value intact, while still being able to change it in the input field programmatically -

how can store user input using js can restore later (i.e. via pressing button).

assume user enters text input field of form, so:

<form> <select name="unit_system" id="unit_system"> <option value="english">english</option> <option value="metric">metric</option> </select> <input class="input_gpm" type="text" value="<?=$value?>" /> </form>

i want able revert originally-entered value, if value in input field changes programmatically, can happen when value converted 1 unit scheme of measurements another.

why not store user input in own variable? using jquery:

var $userinput; $(".input_gpm").on("change", function(){ $userinput = $(".input_gpm").val(); });

then, user inputs value select field, gets stored in $userinput variable storage , future use. rewritten when user manually inputs text input field.

jquery

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -