How can I have refresh page link/button inside my JavaScript code?

andy

Basically I have the following code which checks the user input and gives the output accordingly:

<script>
    function checkUserInput() 
    {
        var userInput = document.getElementById("textInput").value;
        var stringToCheckAgainst = random_images_array[num].split('.');
        if (userInput.toUpperCase() == stringToCheckAgainst[0].toUpperCase())         
        {
            document.getElementById("row1").innerHTML="<p>" + txt.fontsize(5) + "</p>";document.close();
        } 
        else 
        {

            //user has inputted an incorrect string
            document.getElementById("row1").innerHTML="<p>" + txt1.fontsize(5) + "</p>";document.close();
        }
    }
</script>

However my problem is, in the case that the user response is not correct and the programme only displays the “incorrect message”, I need to show a refresh or reset button or text that by clicking on that link the user can again refresh the page and gets a new challenge.

Thiago Custodio
function checkUserInput() {
    var userInput = document.getElementById("textInput").value;
    var stringToCheckAgainst = random_images_array[num].split('.');

    if (userInput.toUpperCase() == stringToCheckAgainst[0].toUpperCase()) {
        document.getElementById("row1").innerHTML="<p>" + txt.fontsize(5) + "</p>";document.close();
    } else {
        //user has inputted an incorrect string
        document.getElementById("row1").innerHTML="<p>" + txt1.fontsize(5) + "<a href='#' onclick='javascript:location.reload();'>Try again</a></p>";document.close();
    }
}
</script>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I inject JavaScript code to periodically refresh a page

Go How can I use JavaScript code on my html page

How can I refresh my live search by hitting on the cross button which is inside the input text field in JavaScript?

How can I make a variable "refresh" itself every time my JavaScript file has code pulled from it?

How can I make the code inside my useEffect react hook re-run when page refreshes?

How can I use page inside of my page.evaluate?

How can I refresh the XPages File Download Control and have it display updated attachments without full page refresh?

How can I debug JavaScript code that is inside JSP page directly from IntelliJ IDEA?

how can i refresh the php file using javascript code?

When i try to refresh my page i have this error

How do I optimize my JavaScript Code that I currently have?

How can I have a different frontmatter for my about page in Hugo?

I can't use Eval inside LinkButton?

How can I dynamically update and execute javascript code in my web page?

How can I insert a block code inside a php page?

I Have to refresh the AngularJS page to see my changes

Is there a limit to how many loops I can have in my code?

Android Code: I have coded for YouTube URL but I can't play videos inside my app

How can I update/refresh Google MDL elements that I add to my page dynamically?

How can I save my previous dice rolls when I refresh the page?

How can I retain my checkbox status even if I refresh the page?

How can I refresh a page with jQuery?

How can I increment a value on page refresh?

How can I save the code of my generated HTML page?

How do I refresh a page using JavaScript?

Javascript: How Do I Refresh Page At Midnight?

How can I have Laravel mix only compile my Javascript?

How can i use DOM events inside my javascript classes?

How can I access PHP array inside my Javascript?