+ 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

5th Oct 2017, 4:10 PM
K1llJ0Y
K1llJ0Y - avatar
4 ответов
+ 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! 😉
5th Oct 2017, 4:37 PM
Zephyr Koo
Zephyr Koo - avatar
+ 6
Just updated my answer. 👆 I overlooked it as we need to display the DOM's value, hence "name.value". 😉
5th Oct 2017, 11:56 PM
Zephyr Koo
Zephyr Koo - avatar
+ 1
this fixed the issue, thanks lots!
5th Oct 2017, 6:19 PM
K1llJ0Y
K1llJ0Y - avatar
+ 1
actually want because now instead of showing the name it just says"[object HTMLInputElement]"
5th Oct 2017, 6:33 PM
K1llJ0Y
K1llJ0Y - avatar