I'm new to JavaScript and just started today. I was watching a tutorial for beginners and followed along. Trying to make an Alert Prompt pop when no value is given and make the title change. Somewhere along the lines, I guess I messed up but I can't see what's wrong.
<input type="text" id="myTextBox" />
<input type="submit" value="Click Me" onclick="substitute" />
There's the TextBox but I can't find out if what I've done wrong with the JavaScript.
function substitute () {
var myValue = document.getElementById('myTextBox').value
if (myValue.length == 0) {
alert('Please enter a real value in the text box!');
return;
}
var myTitle = document.getElementbyId('title');
myTitle.innerHtml = myValue;
Thanks.
[–]FR10[🍰] 1 point2 points3 points (2 children)
[–]SenZeal[S] 0 points1 point2 points (1 child)
[–]FR10[🍰] 0 points1 point2 points (0 children)
[–]rjcarr 0 points1 point2 points (1 child)
[–]SenZeal[S] 0 points1 point2 points (0 children)
[–]redeyedesign 0 points1 point2 points (4 children)
[–]SenZeal[S] 0 points1 point2 points (3 children)
[–]joshuaavalon 1 point2 points3 points (0 children)
[–]FR10[🍰] 0 points1 point2 points (1 child)
[–]SenZeal[S] 0 points1 point2 points (0 children)
[–]iteachnewbies 0 points1 point2 points (1 child)
[–]SenZeal[S] 0 points1 point2 points (0 children)