Thursday, April 30, 2009

How Do u Disable a Web Button after it clicked Till Anther certain button is click to enable the button again?

How Do You Make A Web Button Disable Then Is Enable Again When A Spacific Buttion Is Clicked On.

How Do u Disable a Web Button after it clicked Till Anther certain button is click to enable the button again?
%26lt;html%26gt;


%26lt;head%26gt;


%26lt;script language="javascript"%26gt;


var i=1;


function enabled(idx,nb){


document.getElementById(idx+i).disabled=...


i++;


if (i%26gt;nb) i=1;


}





%26lt;/script%26gt;


%26lt;/head%26gt;


%26lt;body%26gt;


%26lt;center%26gt;


%26lt;input type="button" id="but1" value="button 1" onClick="this.disabled='true';" /%26gt;


%26lt;input type="button" id="but2" value="button 2" onClick="this.disabled='true';" /%26gt;


%26lt;input type="button" id="but3" value="button 3" onClick="this.disabled='true';" /%26gt;


%26lt;input type="button" id="but4" value="Enable" onClick="enabled('but',3);" /%26gt;


%26lt;/center%26gt;


%26lt;/body%26gt;


%26lt;/html%26gt;





NB: I've used id cuz Firefox doesn't like name


To sum up, to enable an element(eg: button) set its proprety element.disabled='true' and to re-enable it use element.disabled=0


No comments:

Post a Comment