• Advertisement
Sign in to follow this  

[web] Javascript on input buttons

This topic is 3324 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, I have a script which shows a few input buttons, and with my javascript I'm trying to get the script to "Disable" which ever button i pressed for X amount of time.... How ever my script doesn't seem to work, the first input button disables correct as does the second one its like they are grouped... but then all the other buttons outputted do nothing. Hope you can help me out... heres what i tried: ---------------------------------------
$Short = 0;
$ShortRange = 3;
//------------------------------
function createInput($num)
{
  return '&lt;input type="submit" id="Short['.$num.']" name="Short['.$num.']" value="Attack number '. $num .'"&gt; <br><br>';
}
//------------------------------
?>
script type="text/javascript"&gt;
  var minNum = &lt;?php echo $Short ?&gt;;
  var maxNum = &lt;?php echo $ShortRange ?&gt;;
  var c = 0;

window.onload = function(){

  for(var i = minNum + 1; i &lt; maxNum; i++)
  {
     counter(i);
  }   
}

function counter(num) {
   var btnattack = document.getElementById('Short['+num+']');
   btnattack.disabled = true;
   if (c &lt; 2) {
      btnattack.disabled = true;
      btnattack.value = 'Wait... ' + (2-c);
      c++;
      setTimeout("counter("+num+")", 1000);
   } else {
      btnattack.disabled = false;
      btnattack.value = 'Attack number '+num;
   }
}
</script>
<?php

While($Short != $ShortRange){
   echo createInput($Short+1)."\n";
   $Short = $Short + 1;
   }
?>
	
--------------------------------------------------- Thanks in advance or any help given. [Edited by - thefollower on January 19, 2009 4:10:48 PM]

Share this post


Link to post
Share on other sites
Advertisement
just use an onclick even to call a function that disables the button. You can even use the same function to set the value of the button so it appears to count down.

Share this post


Link to post
Share on other sites
Quote:
Original post by Feralrath
just use an onclick even to call a function that disables the button. You can even use the same function to set the value of the button so it appears to count down.


I tried but i couldn't get it to work it kept doing the same problem each time. :(

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement