+ 1
How do form tags work because apparantly im not doing it right
so the form is supposed to be able to take the name, then on submission call the function magicEightBall, which uses getElementById to grab the entered name, and echo it by changing that <p> tag https://code.sololearn.com/W3Age1T4MF0i/?ref=app
4 odpowiedzi
+ 10
We got a few problems here:
☑ Form POST follow POST-GET pattern but obviously you don't want the GET which return a blank page to you.
So, replace
onsubmit="magicEightBall()"
with
onsubmit="return magicEightBall()"
and add
return false;
before the end of magicEightBall() function to indicate that you want the terminate the form submission.
☑ Replace "name" with name.value for innerHTML display.
Hopefully it helps! 😉
+ 6
Just updated my answer. 👆
I overlooked it as we need to display the DOM's value, hence "name.value". 😉
+ 1
this fixed the issue, thanks lots!
+ 1
actually want because now instead of showing the name it just says"[object HTMLInputElement]"