
Signature
Greg Collins [Microsoft MVP]
Visit Braintrove ( http://www.braintrove.com )
Visit InfoPathDev ( http://www.InfoPathDev.com )
THANK YOU!
First I tried
/****************************************************/
function OnAfterChange(eventObj)
{
var curNode = eventObj.Source;
var found = false;
while (! found) {
if (curNode.nodeTypeString == "element"){
var modflag = curNode.getAttribute("modflag");
if (modflag != null) { // null is missing
if( modflag != "true" ) {
curNode.setAttribute("modflag","true");
}
found = true;
}
}
curNode = curNode.selectSingleNode("..");
if (curNode == null) {
found = true; // pseudo found - reached top
}
}
return;
}
/****************************************************/
However, that results in an error: "MSXML5.DLL: A text node child of an
attribute may not be passed as the context node for an XSLT transform or an
XPath query."
(eventObj starts out as the text node child of the 'status' attribute, once
for a "Delete" operation to get rid of the existing value, a second time for
an "Insert" operation to add the new value)
SOLUTION:
The code that works is
/****************************************************/
function OnAfterChange(eventObj)
{
var curNode = eventObj.Source;
var found = false;
while (! found) {
if (curNode.nodeTypeString == "element"){
var modflag = curNode.getAttribute("modflag");
if (modflag != null) {
if( modflag != "true" ) {
curNode.setAttribute("modflag","true");
}
found = true;
}
}
else if (curNode.nodeTypeString == "text"){
curNode = curNode.parentNode;
}
else if (curNode.nodeTypeString == "attribute"){
curNode = curNode.selectSingleNode("..");
}
if (curNode == null) {
found = true; // pseudo found - reached top or can't climb higher due to
object model idiosyncracies
}
}
return;
}
/****************************************************/
> In your situation you would do the following:
>
> var parent = curNode.selectSingleNode("..");
>
> This works despite parentNode being null.
Greg Collins [InfoPath MVP] - 04 Apr 2007 18:11 GMT
Glad you got it working. Thanks for the update!

Signature
Greg Collins [Microsoft MVP]
Visit Braintrove ( http://www.braintrove.com )
Visit InfoPathDev ( http://www.InfoPathDev.com )