It looks like you are trying to store your multiple selections in the node to which the list is bound. This won't work for a couple of reasons:
1) As soon as you modify the value of the node, the list will no longer show the selection the user just made.
2) By changing the value of the node, you trigger another OnAfterChange event to occur, which calls the function again -- thus triggering an endless loop, which is only broken by a built-in check which gives you the error message you see.
You need to store the set of user selections in some other node.
--
Greg Collins [InfoPath MVP]
Visit
http://www.InfoPathDev.com
greg, after inserting the code into the onafterchange event handler i get the
error. "An error occurred in the form's code. The number of calls to the
OnAfterChange event for a single update in the data exceeded the maximum
limit." followed by a list of the item I selected from my list.
I am using a drop down list, which is populated from a secondary data source
and filtered by another drop down list, could this have anything to do with
it?
The coding for reference:
function msoxd__ROS_PMH_ReviewIndividualSystems_attr::OnAfterChange(eventObj)
{
// Write code here to restore the global state.
{
if (eventObj.IsUndoRedo|| "Insert" != eventObj.Operation)
return;
var oChoice =
XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d

emographics/d:ROS_PMH/@ROS");
if("" == oChoice.text)
return;
var oSelectionsViaCode =
XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d

emographics/d:ROS_PMH/@ReviewIndividualSystems");
if("" == oSelectionsViaCode.text)
oSelectionsViaCode.text = oChoice.text;
else
oSelectionsViaCode.text += " " + oChoice.text;
return;
}
// A field change has occurred and the DOM is writable. Write code here to
respond to the changes.
}
Greg Collins said:
Check out the following article:
Keep Track of List Selections
http://www.infopathdev.com/howto/tutorials/default.aspx?i=3747acf3968448a992abcc76d54bf920
--
Greg Collins [InfoPath MVP]
Visit
http://www.InfoPathDev.com
hello, I was wondering if there is a way to create a list of selections from
a drop down list. once the user selects a value from the drop down list it is
entered into another section, and if the user selects another item from the
list it is added to the list of already selected items. havent run across
any solutions as of yet, but it would be extremely useful to have. thanks in
advance for the help. ~Mike