I created some forms and dropdowns and got Javascript to find the values of the forms and dropdowns.
However, when I try to print these values I get either the default value of the dropdown or ‘undefined’ for a form, even when I’ve put text into them. How can I update the values?
There are several similar questions posted, I know, but I don’t know whether their answers are relevant to my situation because I am new to Javascript.
Anyway the full page can be found via pastebin here: http://pastebin.com/DpcrsfxN.
Instead of
Use
and then to update the value of this input you’d simply do
Also, it looks like you have this script right out in the open, after your body section:
This will always print the default value of the input when the user submits the form because you’re reading and saving this value right after the page is rendered.
You’ll want to read these values fresh from inside of the
printVariablesfunction