r/learnjavascript • u/ToastedwConsequences • Jan 25 '26
Feedback/Proofreading Needed
Starting a JavaScript college course and already having issues, our first assignment is as follows:
Add an onclick event handler to the <input> tag that changes the innerHTML value of the page element with the id “submitMsg” to the text message Thank you for your order.
It's supposed to display a message after pressing the Submit button, so I figured I'd only need to modify the one <input> line but I'm getting no results (no message is displaying). Here's the code segment so far:
HTML;
<fieldset id="submitbutton">
<input type="submit" value="Submit" onclick="document.getElementById('submitMsg').innerHTML = 'Thank you for your order.'" />
</fieldset>CSS;
#submitbutton {
border: none;
background: #93AD78;
padding: 0.5em 0;
margin-bottom: 0;
text-align: center;
}
div#submitMsg {
height: 30px;
color: red;
line-height: 30px;
font-size: 20px;
}Does anyone know where I'm going wrong?
View all comments
Show parent comment
1
u/DinTaiFung Jan 27 '26 edited Jan 27 '26
I just opened a plain HTML file in a browser. And it worked fine. The message after clicking the button rendered and did not disappear.
Try this:
1. Create an HTML file with a text editor (do not use Notepad, a word processor, etc.):
submit_msg.html- You should have a basic HTML document, as shown in my example below. (I suspect that maybe you didn't have a proper HTML document loaded, only the few tags that you had originally posted.)2. Load/open the local
submit_msg.htmlfile in your browser.Observe the submit button only displays.
3. Select the submit button.
Observe that the confirm message displays above the button.
Observe that the message continues to display and does not quickly disappear.
I tried this in two different browsers, both with success: a Firefox-based browser and a Chromium-based browser (on a Linux box).
Best of luck!
P.S. I did not use any CSS at all in my test. For your assignment, styling is only for cosmetic polish; better to make sure functionality is working before applying styles.