1

So many years in web development and still learning.

Is there any way to modify an input element of type hidden's value without modifying the html attribute? As if the user entered a value. I need to be able to set a value but then upon calling form.reset() to return to the original value.

Notice: I'm not looking for a workaround, I want to know how to do the thing I asked for in particular.

php_nub_qq
  • 15,199
  • 21
  • 74
  • 144

2 Answers2

1

No way to do it properly https://jsfiddle.net/m4bn7ax3/1/

What if you hide an input text? May it be an acceptable workaround?

<input type="text" style="display: none" name="foo" value="original">
Simone Sanfratello
  • 1,520
  • 1
  • 10
  • 21
0

you can use javascript to set the input field value. Initialise the default value in a variable and then plug that into the input by setting the input field value to that variable in your form.reset() method.

document.getElementById("idOfInputField").value = defaultValue;
Berdesdan
  • 359
  • 1
  • 5
  • 12