Using HTML forms as input for JavaScript. Not working | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Using HTML forms as input for JavaScript. Not working

I want to create a form text box as an input in a JavaScript program I'm making (as opposed to using prompt for input). I'm trying to get the value (what you type into the box) and assign a object property to it. I also want the function to be able to be used in other programs later, so I'm trying to make it general, with any specific parts being arguments of the function. The issue is somewhere between taking the value and assigning the object. Please help! I isolated the functions in the attached code link. Thank you https://code.sololearn.com/WK5NFXiF8PCH/#js

11th Dec 2019, 8:24 PM
JJ McSquiggles
JJ McSquiggles - avatar
2 Answers
+ 1
In function ‘getFieldValue’ type after(); not after;
12th Dec 2019, 3:22 PM
Tomáš Wróbel
Tomáš Wróbel - avatar
0
Tomáš Wróbel, I tried adding () to after and it will delete the from and put 0 it it's place. It should wait for you to click the button then take whatever is typed and change o1.a from 0 to whatever you typed. Then, it should delete the form and button and say whatever o1.a is (which is what you typed in the box). But instead it is deleting the form, and not the button, and replacing it with 0, which is the current value of o1.a. Is the eventListener not working because it is calling after() before you click on the button?
12th Dec 2019, 6:07 PM
JJ McSquiggles
JJ McSquiggles - avatar