S
stingbot
Hi,
I'm trying to select a node in my form using a changing variable.
Due to the way i need to display text and due to this field being in a
section inside of a repeating section already, i havent been able to
rework the form to be entirely repeating.
I have this code at the moment:
function ParseDate(date,NodeName)
{
var oldDate;
//this is used to hold the ISO formatted date
var newDate;
//this is used to hold the date after it has been changed
oldDate = date;
//set this variable with the date passed from the calling function.
newDate = oldDate.substring(8,10) + "/" + oldDate.substring(5,7) + "/"
+ oldDate.substring(0,4);
//convert date to dd/mm/yyy
var str1 = '//my:';
//start path to xml node
var str2 = NodeName;
//finish path to xml node taken from parameter in function name
var FieldToChange = str1.concat(str2);
//combine the 2 strings to make the whole path.
var NewDateNode = XDocument.DOM.selectSingleNode(FieldToChange);
//select the node defined in FieldToChange
newDateNode.text = newDate;
//Set chosen field on the form with the new date format
}
I get NewDateNode is undefined, and when i debug i find that
NewDateNode is not being set from FieldToChange
FieldToChange is the proper xml path. "//my:Australian_Date", I can see
this with a XDocument.UI.Alert(FieldToChange);
The whole point is that I was trying to write a function that I could
reuse on various fields to insert the correct date (07/08/2006,
dd/mm/yyyy) for Australia, as the ISO date format doesnt look nice in
any reports generated by the form. A Date picker control is used to get
the date parameter in the function name.
I am trying not to write this block of code for each and every field I
want to do this to.
Any Help or comments appreciated.
I'm trying to select a node in my form using a changing variable.
Due to the way i need to display text and due to this field being in a
section inside of a repeating section already, i havent been able to
rework the form to be entirely repeating.
I have this code at the moment:
function ParseDate(date,NodeName)
{
var oldDate;
//this is used to hold the ISO formatted date
var newDate;
//this is used to hold the date after it has been changed
oldDate = date;
//set this variable with the date passed from the calling function.
newDate = oldDate.substring(8,10) + "/" + oldDate.substring(5,7) + "/"
+ oldDate.substring(0,4);
//convert date to dd/mm/yyy
var str1 = '//my:';
//start path to xml node
var str2 = NodeName;
//finish path to xml node taken from parameter in function name
var FieldToChange = str1.concat(str2);
//combine the 2 strings to make the whole path.
var NewDateNode = XDocument.DOM.selectSingleNode(FieldToChange);
//select the node defined in FieldToChange
newDateNode.text = newDate;
//Set chosen field on the form with the new date format
}
I get NewDateNode is undefined, and when i debug i find that
NewDateNode is not being set from FieldToChange
FieldToChange is the proper xml path. "//my:Australian_Date", I can see
this with a XDocument.UI.Alert(FieldToChange);
The whole point is that I was trying to write a function that I could
reuse on various fields to insert the correct date (07/08/2006,
dd/mm/yyyy) for Australia, as the ISO date format doesnt look nice in
any reports generated by the form. A Date picker control is used to get
the date parameter in the function name.
I am trying not to write this block of code for each and every field I
want to do this to.
Any Help or comments appreciated.