Answered by:
Multiple check boxes in CRM 4.0

Question
-
There is an attribute A whose type is picklist. Another attribute B has multiple check box values.Multiple options can be selected.When I select a value from A,some set of multiple options needs to be displayed for B.When I select another value from picklist,some other set of multiple options needs to be displayed for B.I have written the code and it is working fine.but there is one issue.When the last value is selected from the dropdown and the corresponding check boxes,on saving, the values are shown ticked.if I select the 3rd dropdown value, the corresponding checkbox values are not ticked after saving.same is the case for 1st and 2nd.it becomes unticked.
If I reduce the no of drop down values to 3,then again the last values are saved and not the other 2.why is this happening??please advise
- Changed type HIMBAPModerator Friday, June 27, 2014 10:29 AM
Friday, June 27, 2014 6:53 AM
Answers
-
Thanks Mahender for the reply.but i am using the below code 4 times as I have 4 dropdown values to select from.it is only saving the multiple check boxes associated with the last dropdown value.please help.Thanks in advance
// PL - the picklist attribute; PLV - used to save selected picklist values
var PL = crmForm.all.new_picklist;
var PLV = 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 />"); //it's a 'br' flagPL.nextSibling.appendChild(addInput);
PL.nextSibling.appendChild(addLabel);
PL.nextSibling.appendChild(addBr);
}
// Check if it is selectedfunction 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 FindcrmForm.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 + "||";
}
}
}
}- Marked as answer by Bachchan11 Monday, October 6, 2014 11:48 AM
Friday, June 27, 2014 11:58 AM
All replies
-
Did you try to debug your code and checked if you selected value is storing in the dummy text box (assuming you are storing all values in textbox and then reading from there to make selection) correctly on selection ??
Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Friday, June 27, 2014 10:30 AMModerator -
Thanks Mahender for the reply.but i am using the below code 4 times as I have 4 dropdown values to select from.it is only saving the multiple check boxes associated with the last dropdown value.please help.Thanks in advance
// PL - the picklist attribute; PLV - used to save selected picklist values
var PL = crmForm.all.new_picklist;
var PLV = 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 />"); //it's a 'br' flagPL.nextSibling.appendChild(addInput);
PL.nextSibling.appendChild(addLabel);
PL.nextSibling.appendChild(addBr);
}
// Check if it is selectedfunction 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 FindcrmForm.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 + "||";
}
}
}
}- Marked as answer by Bachchan11 Monday, October 6, 2014 11:48 AM
Friday, June 27, 2014 11:58 AM