Skip to content

Enabling Disabling CheckBoxList on Client side using java script

December 4, 2012

Enabling Disabling CheckBoxList on Client side using java script

http://forums.asp.net/t/1347624.aspx/1

//Add This Code To the HTML directly
// checkboxlistID = id of the checkboxlist
// chkarray = array of indexes to set enable or disable
// disable = true to disable
<script language=javascript>
function disableListItems(checkBoxListId, chkArray, disable)
{
// Get the checkboxlist object.
objCtrl = document.getElementById(checkBoxListId);

// Does the checkboxlist not exist?
if(objCtrl == null)
{        return;
}

var i = 0;

// iterate through listitems that need to be enabled or disabled
for(i = 0; i<chkArray.length; i++)
{
objItem = document.getElementById(checkBoxListId + ‘_’ + chkArray[i]);

if(objItem == null)
{
continue;
}

// Disable/Enable the checkbox.
objItem.disabled = disable;
// Should the checkbox be disabled?
objItem.checked = false;

}
}
</script>

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: