I have basically created a table that is made of two rows, the first row checks if the user input is correct or not, and the second row is displaying a button. I have used the following code inside my script function inside the first row of my table to display the output response:
function checkUserInput() {
var userInput = document.getElementById("textInput").value;
var stringToCheckAgainst = random_images_array[num].split('.');
//this splits the item at the array index into an array, like so.
If the item is "apple.gif", the array reads ["apple", "gif"]
if (userInput == stringToCheckAgainst[0]) {
//user has inputted the correct string
//window.alert("user gave correct response!");
document.write("<p>" + txt.fontsize(5) + "</p>"); document.close();
} else {
//user has inputted an incorrect string
//window.alert("user gave incorrect response!");
document.write("<p>" + txt1.fontsize(5) + "</p>"); document.close();
}
}
</script>
However this code will delete the entire page (document). Can anyone advise me how to write the message only the top section of my page (or table) and leave the second row of my table unchanged?