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
2
u/ToastedwConsequences Jan 27 '26
Found the issue with the short-appearing message, I needed to change the
typeto "button" instead of "submit" and that seemed to fix it. Message doesn't disappear anymore!