/*
Checkbox style multi-select picklist
Author: Jim Wang @ January 2009
Http://jianwang.blogspot.com
Http://mscrm.cn
*/
//Pl-The picklist attribute; PLV-used to save selected picklist values
VaRPL=Crmform. All. new_picklist;
VaRPLV=Crmform. All. new_picklistvalue;
If (PL ! = Null && PLV ! = Null )
{
Pl. style. Display = " None " ;
PLV. style. Display = " None " ;
// Create a div container
VaR Adddiv = Document. createelement ( " <Div style = 'overflow-Y: auto; Height: 80px; Border: 1px # 6699cc solid; Background-color: # ffffff; '/> " );
Pl. parentnode. appendchild (adddiv );
// Initialise checkbox controls
For ( VaR I = 1 ; I < Pl. Options. length; I ++ )
{
VaR Poption = Pl. Options [I];
If ( ! Ischecked (poption. Text ))
VaR Addinput = Document. createelement ( " <Input type = 'checkbox' style = 'border: none; width: 25px; align: Left; '/> " );
Else
VaR Addinput = Document. createelement ( " <Input type = 'checkbox' checked = 'checked' style = 'border: none; width: 25px; align: Left; '/> " );
VaR Addlabel = Document. createelement ( " <Label/> " );
Addlabel. innertext = Poption. text;
VaR Addbr = Document. createelement ( " <Br/> " );
Pl. nextsibling. appendchild (addinput );
Pl. nextsibling. appendchild (addlabel );
Pl. nextsibling. appendchild (addbr );
}
// Check if it is selected
Function Ischecked (ptext)
{
If (PLV. Value ! = "" )
{
VaR Plvt = PLV. value. Split ( " | " );
For ( VaR I = 0 ; I < Plvt. length; I ++ )
{
If (Plvt [I] = Ptext)
Return True ;
}
}
Return False ;
}
// Save the selected text, this filed can also be used in Advanced Find
Crmform. attachevent ( " Onsave " , Onsave );
Function Onsave ()
{
PLV. Value = "" ;
VaR Getinput = Pl. nextsibling. getelementsbytagname ( " Input " );
For ( VaR I = 0 ; I < Getinput. length; I ++ )
{
If (Getinput [I]. Checked)
{
PLV. Value + = Getinput [I]. nextsibling. innertext + " | " ;
}
}
}
}
The style of the DIV must specify 'overflow-Y: auto ;'
Reference: http://www.cnblogs.com/MSCRM/articles/1377386.html