Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,583 members, 7,809,114 topics. Date: Thursday, 25 April 2024 at 11:38 PM

Button Countdown Need Improvement Javascript - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Button Countdown Need Improvement Javascript (799 Views)

My 6weeks Improvement On Web Programming: Photos / Facebook Message Button / After 10days Of Coding With Html, Css And Javascript Forum4africa Is Ready (2) (3) (4)

(1) (Reply)

Button Countdown Need Improvement Javascript by skyhighweb(m): 9:09am On Feb 23, 2018
please please please am not a javascript guy i need an improvement on this script i pasted it here a long tme ago i got lectures more than help lol so please heres the script below, i only want to add a visible count down the button but doesnt show the count down it only blurs the button until countdown is over the button becomes active thanks

```
<input type="button" id="submit" value="submit" class="btn" />
<script type="text/javascript">

$(function(){
Program.Init();
});

var Program = {

Init: function(){
this.$target = $('#submit').attr("disabled", true);
this.EnableSubmit();
this.EventHandler();
},

EnableSubmit: function(){
var value = this.Cookies.Get('submit_button');
var now = Date.now();
if( !value ) {
this.$target.removeAttr("disabled"wink;
return;
}
setTimeout(function() { Program.EnableSubmit(); }, value - now);
},

Submit: function(){
this.$target.attr("disabled", true);
this.Cookies.Set('submit_button', Date.now() + 10000, 0.25, { expire_in: 'minutes' });
setTimeout(function() { Program.EnableSubmit(); }, 10000);
},

EventHandler: function(){
this.$target.on('click', function(){ Program.Submit(); });
},

// methods to manage cookies easily used above
Cookies: {

Get: function (name) {
var n, ca, c;
n = name + "=";
ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
c = ca[i].trim();
if (c.indexOf(name) === 0) return c.substring(name.length + 1, c.length);
}
return false;
},

Set: function (name, value, expire, options) {
var d = new Date(), expires;
var defaults = { expire_in: 'days', path: '/' };
if (options !== undefined) $.extend(true, defaults, options);
if (expire !== undefined && expire !== null) {
if (defaults.expire_in == 'days') d.setDate(d.getDate() + expire);
else if (defaults.expire_in == 'minutes') d.setTime(d.getTime() + (expire * 60 * 1000));
else {
console.log('expire_in configuration is not valid');
}
expires = "expires=" + d.toGMTString();
}
else expires = expires = "";
document.cookie = name + "=" + value + "; " + expires + '; path=' + defaults.path;
return true;
}

}

};

</script>


```

(1) (Reply)

Spring Java And Android Personal Tutor Needed / Get Personal Composed Customizable Website Design| Programming Proposal / IF You Can And Have Developed Android Or Ios App We Have A Job For You

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.