View Full Version : Enabling disable butons

08-19-2005, 10:25 PM
Hi guys 'n' gals,

been really busy and not had chance to peek in. HAve question though.

Have a button that needs to be enabled when server side scripting builds and populates a dynamic array, so will be written to teh client by the server. anyways.

Bit of a dead end as the Enabled/Disable are not named attributes, they are arbritrary, so any ideas on how to enable them using client side script?

ideas,code or pointers would be greatly apprecieted.


kai :thumbsup:

08-20-2005, 08:13 AM
<input type='button' id='MyButton' disabled>

function Disable(){
document.getElementByID('MyButton').disabled = false;

Then just run the function however fits your needs.

08-22-2005, 02:04 PM
You can also enable the button in the server-side by not including the disabled property in the input tag. Have a variable that contains the string "disabled" or "" based on some conditions.

08-22-2005, 05:57 PM
<script type="text/javascript">
function togglebutton(wichbutton){
var button = document.getElementByID(wichbutton)
if (button.disabled=true) {
button.disabled = false
} else {
button.disabled = true
</script>With that you can disable or enable any button any time you wish...