Jump to content

Disable button at set date / time


WAMFT1
Go to solution Solved by Barand,

Recommended Posts

Is there a way that you can disable a button at a set date and time?

 

For example, my work has a competition site running and I want to give people the option to change their weekly selections by clicking on an edit button up to 6pm on a certain Friday. After this time it either disappears or is just made inactive.

 

ie:

 

Comp 1 -> 'Edit' then disable after 6:00pm 2nd Jan

Comp 2 -> 'Edit' then disable after 6:00pm 9th Jan

Comp 3 -> 'Edit' then disable after 6:00pm 16th Jan etc....

 

I am not even sure where to start with this one.

Link to comment
Share on other sites

<?
if (time() > strtotime("12/31/2014 6:00PM"))
{ <input name="Disabled" type="button" disabled="disabled" value="Disabled" />; }else{
<input name="Enabled" type="button" value="Enabled" />;}
?>

I have figured out part of this but don't know what to do to get the button to display. Any ideas?

Link to comment
Share on other sites

<?
if (time() > strtotime("01/02/2015 5:00PM"))
{ echo'<input name="Disabled" type="button" disabled="disabled" value="Disabled" />'; }else{
echo'<input name="Enabled" type="button" value="Enabled" onclick="location.href='../edit.php'"/>';}
?>

Thanks Barand, Works great, I have tried to link the button to another page but it doesn't work. What am I missing? any suggestions?

Link to comment
Share on other sites

Thanks Barand, worked a treat.

 

Thanks ginerjm, displaying the disabled button is an OCD thing of mine in that it there is symmetry in the look of the page. In the instance of this site the rechecking won't be much of an issue as the login script expires the page after 30 minutes and the cut off time is a good 2 hours earlier. Even if they were late they are still early if you get what I mean.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.