This is my second day of doing anything at all with javascript so I am a complete beginner. As the title states, I just want to change the text value of a textbox using the settimeout function. I have searched the internet and have come to a dead end. This is what I have so far,
putftp.onclick = function () {
var Text = document.getElementById("TextBox");
function firsttext() {
document.getElementbyID("TextBox").innerHTML = "This is the first test.";
setTimeout("secondtest()",3000);
}
function secondtest() {
document.getElementById("TextBox").innerHTML = "This is the second test.";
setTimeout("thirdtest()",5000);
}
function thirdtest() {
document.getElementById("TextBox").innerHTML = "This is the last test.";
}
};
Im not sure if Im using the correct format, or if Im even anywhere close to being correct. Im pretty sure everything is ok except for the document.getElementbyID(“textbox”).innerHTML part. I would think something there would be changed, but its only my second day so I really could be clueless about this whole issue. Thanks for your help in advance!
To change the text once 3 seconds after the button click, have this:
You have two errors in your orignal code which I fixed for you:
TextBoxis a text box, you need to assign itsvalueproperty, notinnerHTML.getElementByIdand notgetElementbyID. JavaScript is case sensitive.To change it again two seconds later, you can add “nested” timer:
Live test case.