Chapter 12 Try it out
The Try it out in Chapter 12 was to write code to put 2 names together using infopath jscript
Basically two boxes with first name and surname then below two boxes would combine the first box was surname comma first name and the second box was firstname space surname
The code in jscript is
function createFullName()
{
var firstnameField = XDocument.DOM.selectSingleNode("//my:txtFirstName");
var lastnameField = XDocument.DOM.selectSingleNode("//my:txtLastName");
var lastfirstwithcommaField = XDocument.DOM.selectSingleNode("//my:txtLastFirstWithComma");
var fullnameField = XDocument.DOM.selectSingleNode("//my:txtFullName");
if ((firstnameField.text.length>0) && (lastnameField.text.length>0))
lastfirstwithcommaField.text=lastnameField.text + ', ' +
firstnameField.text;
fullnameField.text=firstnameField.text + ' ' + lastnameField.text
}
Has anyone written this code using vbscript?
Also the book writes code in jscript is it better to code in jscript than vbscript in infopath
Let me know
Thanks
Richard
|