I’m in an introduction to web programming class and am having trouble with my code. Any help is appreciated. This is not for a specific lesson on codecademy, all I am trying to do is make an html webpage that asks something simple like “what is your favorite fruit” and then display whatever the user enters into the text box.
Here is my code -
The problem is nothing is displaying. I have changed lines of code and tried different tactics to get anything to display and I can’t seem to get it to do anything. Preferably, I want to be able to say something like “You have chosen Apples!” using
document.write("You have chosen " + strFavFruit + "!")
I’ve looked online and one website said that using the document.write() function erases all html left on the page if its done after the page is loaded, and to only use it when debugging really.
I just want to be able to display it in one line instead of
<p>You have chosen</p> <p id="fruit"></p> <p>!</p>
Coming out in 3 different lines. So there you go. Two different problems.
- I want it to work
- I want it to display in one line
How do I do this?
Thanks in advance.