Reply
Help me with Button
Old 11-17-2006, 09:28 PM Help me with Button
Experienced Talker

Posts: 31
Name: Paul
I want to make this:
When page loads there will be a button, but I want for it to be disabled (can't click it) for specified time.

For example when page loads I want the button to look like this:
"Submit (10)" after 1 second - "Submit (9)" and so on....
when the timer reaches 0, the button would be enabled, so now you can click it, it will work and redirect you to any specified location.

Thank you for help
Athlon1600 is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 11-18-2006, 09:38 AM Re: Help me with Button
Skilled Talker

Posts: 84
http://www.microsoft.com/technet/scr...5/hey0314.mspx any help?
dodz is offline
Reply With Quote
View Public Profile
 
Old 11-18-2006, 10:48 AM Re: Help me with Button
Experienced Talker

Posts: 31
Name: Paul
that's for visual basic
I need html code for that
Athlon1600 is offline
Reply With Quote
View Public Profile
 
Old 11-18-2006, 11:39 AM Re: Help me with Button
Skilled Talker

Posts: 84
THB, I'm not entirely sure it's doable with HTML. I know it's doable with Javascript.

I'm a little rusty with JS so I dunno if this will work or not....


Code:
function init() {
  var o = document.getElementById('blah');
  o.count_down = 10000;
  count(o);
}
function count(o) {
  if(o.count_down) {
    o.count_down -= 1000;
    o.value = 'submit('+o.count_down/1000+')';
    window.setTimeout(function() {
      count(o); }, 1000);
  }
  else {
    o.value = 'submit';
    o.disabled = false;
  }
}
onload = init;
And you'll need to add this code to the page
Code:
<input type='submit' id='blah' disabled='disabled' value='submit(10)' />

Last edited by dodz : 11-18-2006 at 11:42 AM.
dodz is offline
Reply With Quote
View Public Profile
 
Old 11-18-2006, 12:48 PM Re: Help me with Button
Experienced Talker

Posts: 31
Name: Paul
It works.
I actually posted the same thread in "Javascript" forum section. Got the same answer too
Thank for help anyways
Athlon1600 is offline
Reply With Quote
View Public Profile
 
Old 11-18-2006, 01:15 PM Re: Help me with Button
Mooofasa's Avatar
Defies a Status

Posts: 1,612
Name: Michael (mik) Land
Location: England
Making it in VisualBasic6 would be even easier, but this is not VB and it won't help for the web neither.

It's not doable in pure HTML as it requires client-side scripting language.

Just make sure to provide an alternative method for Javascript-disabled browsers.

Before implementing dodz script, make sure to change variable names and id 'blah' to useful ones.
__________________
Tumblings.co.uk - Tumblog with thoughts, quotes, links, videos, images and my creations.
Opera Browser - The best free web browser.
Opera Dev Tools - Firefox is now Firefail.
Mooofasa is offline
Reply With Quote
View Public Profile Visit Mooofasa's homepage!
 
Old 11-18-2006, 01:24 PM Re: Help me with Button
Skilled Talker

Posts: 84
Quote:
Originally Posted by dodz View Post
THB, I'm not entirely sure it's doable with HTML. I know it's doable with Javascript.

I'm a little rusty with JS so I dunno if this will work or not....


Code:
function init() {
  var o = document.getElementById('blah');
  o.count_down = 10000;
  count(o);
}
function count(o) {
  if(o.count_down) {
    o.count_down -= 1000;
    o.value = 'submit('+o.count_down/1000+')';
    window.setTimeout(function() {
      count(o); }, 1000);
  }
  else {
    o.value = 'submit';
    o.disabled = false;
  }
}
onload = init;
And you'll need to add this code to the page
Code:
<input type='submit' id='blah' disabled='disabled' value='submit(10)' />
o.o Really? Hehe, well it's probably correct then.
Good luck.
dodz is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help me with Button
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15698 seconds with 12 queries