Tuesday, September 8, 2009

CRM 4.0 Creating a Readonly picklist

CRM Picklist control (HTML select tag) does not have a read-only attribute like other input html controls. The only way to make it read-only is to disable it which grays out the control completely. Once you disable the Picklist you can’t change its border or font color (i.e. make it look like a read-only field). The only way to achieve the functionality is to change the control behavior so each time the user tries to change the Picklist value the Picklist initial value is re-selected.

Here is the JS code that does the job:


function OnCrmPageLoad()
{
ReadOnlyPicklist(crmForm.all.);
}

function ReadOnlyPicklist(picklist)
{
picklist.savedIndex = picklist.selectedIndex;
picklist.onchange = function()

{
this.selectedIndex = this.savedIndex;
}
}

OnCrmPageLoad();

1 comment:

Blogger said...

If you are interested in making money from your websites via popup advertisments, you can try one of the most reputable companies - Propeller Ads.