I'm trying to set the values of fields on my XML form using javascript. I have no problem setting text values using the selectSingleNode method:
XDocument.DOM.selectSingleNode("/my:myFields/my:strField1").text = "hello world";
However, if I wan to set the value of a non-text field usinig similar code:
XDocument.DOM.selectSingleNode("/my:myFields/my:dtField1") = "5/5/2008";
Or even the hypothetical:
XDocument.DOM.selectSingleNode("/my:myFields/my:dtField1").date = "5/5/2008";
I get the error, "Object does not support this property or method."
Now, I realize that I'm representing my date as a string here, which probably isn't helping things, but this brings up another issue: How do represent dates in javascript? In VBA, I would use the number sign to surround the date (e.g. dtToday = #4/21/2008#), but in javascript I get an invalid character error.
Since I was working with a string anyway, I thought I'd go back to my original statement to see if it would work with the date:
XDocument.DOM.selectSingleNode("/my:myFields/my:dtField1").text = "5/5/2008";
Which gave me the error, "#PCData in nil content." I went into the schema and removed the nillable attribute on the date field, which allowed me to force my string into the date field, but of course it created a validation error because I was forcing a string into a date field. At this point it occurred to me that I was probably making things harder than they had to be, so I thought I'd post it here.
So, basically, my question is this: If I have a date field on an XML form, how do I assign it the value 5/5/2008 (or any specific date value) using javascript?