I Need Help Adding Count Down To This by skyhighweb(m): 5:08pm On Jan 16, 2018 |
<style type='text/css'> /* Lets use a Google Web Font */ input[disabled] { background-color:#FF6347; } </style>
<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" return; } setTimeout(function() { Program.EnableSubmit(); }, value - now); },
Submit: function(){ this.$target.attr("disabled", true); this.Cookies.Set('submit_button', Date.now() + 8000, 0.25, { expire_in: 'minutes' }); setTimeout(function() { Program.EnableSubmit(); }, 8000); },
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>
thank you |
Re: I Need Help Adding Count Down To This by nnamdiosu(m): 10:54pm On Jan 19, 2018 |
Bro...its difficult to read code on a web page like this. Therefore simply state the problem you are having to make it easier to help you...or better still what u want to do so we can help you straight away. Peace |
Re: I Need Help Adding Count Down To This by webdeveloperqx: 11:29am On Jan 20, 2018 |
skyhighweb:
<style type='text/css'> /* Lets use a Google Web Font */ input[disabled] { background-color:#FF6347; } </style>
<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" return; } setTimeout(function() { Program.EnableSubmit(); }, value - now); },
Submit: function(){ this.$target.attr("disabled", true); this.Cookies.Set('submit_button', Date.now() + 8000, 0.25, { expire_in: 'minutes' }); setTimeout(function() { Program.EnableSubmit(); }, 8000); },
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>
thank you put your code on codepen.io and share the link , a well formatted code with linting will always receive help from those who can help than what you just posted here in plain . |
Re: I Need Help Adding Count Down To This by skyhighweb(m): 11:47am On Jan 20, 2018 |
okay |
Re: I Need Help Adding Count Down To This by skyhighweb(m): 1:19pm On Jan 20, 2018 |
|