Dev P
Dev P

Reputation: 1187

Disabling submit button

Hi I have the following code:

<html dir="ltr" lang="en">

<head>

<meta charset="utf-8" />

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> 
</script>

<script type="text/javascript">
<!--//--><![CDATA[//><!--
$(document).ready(function()
{
    $('#yourSubmitId').click(function()
    {
        /*$(this).attr('disabled',true);*/
        $(this).prop('disabled',true);
        $(this).css({display:'none'});

        /* your submit stuff here */

        return false;
    });

    /*refreshing the page bringas back the submit button*/
    window.location.reload();
});
//--><!]]>
</script>

</head>
<body>

<h2>Test disabling submit button for 1 minute...</h2>

<br/>


<form id="yourFormId" name="yourFormId" method="post" action="#">
<input type="image" id="yourSubmitId" name="yourSubmitId" src="C:\images 
\submitButton_grey.jpg" alt="Submit" />
</form>
</body>
</html>

Currently the submit button get disabled and hidden after it has been pressed.

How do I go about refreshing the page in order to bring back the submit button only after 1 minute after the submit button has been pressed..

Thanks,

Upvotes: 0

Views: 179

Answers (1)

nnnnnn
nnnnnn

Reputation: 150030

You don't really need to disable the button if it's going to be hidden anyway with display:'none', and you don't need to refresh the page if you just un-hide the button instead. So you could just do this:

$(this).hide(1).delay(60000).show(1);

If you pass a duration to .hide() and .show() (even a short duration like 1ms) then the hide and show effects are added to the animation queue and you can therefore use the .delay() method in between them.

For more generic delayed execution use the setTimeout() function.

Upvotes: 8

Related Questions