XForms and Microsoft InfoPath[5]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

ewval ) { if (node.firstChild) { node.firstChild.nodeValue = newval; } else { var textnode = node.ownerDocument.createTextNode( newval ); node.appendChild( textnode ); } } function sum(xpath) { var nodes = XDocument.DOM.selectNodes(xpath); var total = 0; for (var idx=0; idx<nodes.length; idx++) { total = total + parseFloat(getElementValue(nodes[idx])); } return total; } function floatToString(value) { return "" + value; }

This script approach requires a bit of care in getting and setting values from XML elements. In accordance with the DOM worldview, actual data values are stored in a text node child of the element node, except that an empty value is signified by the lack of any text child node.

On my initial attempt at this script, I neglected to attach an OnLoad entry point. The solution seemed to work, but had a subtle bug: if the initial value in the currency selection list was never changed, the currency value never got propagated throughout the XML. One advantage of a declarative approach is that it applies equally to initial conditions as well as the ongoing state. The XForms example didn't have to be special-cased for initialization.

Though not used here, the extensive sample forms that come with InfoPath include a large library of script that can be reused via copy-and-paste. The resulting InfoPath document can be filled out in the same application that designed the form, as shown in figure 2.

The data entry view of Microsoft InfoPath
The data entry view of Microsoft InfoPath
(click for larger image)

本文关键:XForms and Microsoft InfoPath
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top