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

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -