I'm creating a site where users can bid on items in a silent auction. I want to be able to somehow start a timer and then let users bid on the items. Once the timer reaches a certain number, I want to be able to remove the bid feature on the auction items.
Does anyone know the best approach for me to do this and what functions or plugins may be helpful? I would prefer a pure PHP approach, but I imagine a mix between PHP and jQuery would most likely solve my problem somehow? Any suggestions? How can I do this?
Thank you in advance!
What I'd do is set an end date on the database entry associated with the auction. Then you just need to check if the current date is before or after the end date.
Then in the front end you can either display the difference between the end date and the current date simply or using some javascript.
Of course it is important that you check that the auction is not over in your php before doing anything since it is really easy to bypass javascript.
jQuery Countdown , This Plugin might help u
Check The "Callback Events" section , that what u need to utilized.
It's Something Like This
$('#shortly').countdown({until: shortly,
onExpiry: liftOff, onTick: watchCountdown});
$('#shortlyStart').click(function() {
shortly = new Date();
shortly.setSeconds(shortly.getSeconds() + 5.5);
$('#shortly').countdown('change', {until: shortly});
});
function liftOff() {
alert('We have lift off!');
}
function watchCountdown(periods) {
$('#monitor').text('Just ' + periods[5] + ' minutes and ' +
periods[6] + ' seconds to go');
}
精彩评论