Deafualt the current Date

H

Help Me

I am using the following code to try to autofill a date time picker with the
current date. But it is giving me a null or is not an object error on the
line that says "if (xmlNode.getAttribute("xsi:nil")) " Can anyone see why?

function XDocument::OnLoad(eventObj)
{
if (!(XDocument.IsNew))
return;

if (XDocument.IsSigned)
return;

var now = new Date();

var xmlNode =
XDocument.DOM.documentElement.selectSingleNode("my:myFields/my:DateSubmitted");

if (xmlNode.getAttribute("xsi:nil"))
xmlNode.removeAttribute("xsi:nil");
xmlNode.text = getDateString(now);
}

function getDateString(oDate)
{
if (oDate == null)
oDate = new Date();

var m = oDate.getMonth() + 1;
var d = oDate.getDate();

if (m < 10)
m = "0" + m;

if (d < 10)

d = "0" + d;

return oDate.getFullYear() + "-" + m + "-" + d;
}
 
A

Andrew Watt [MVP - InfoPath]

Hi,

Was using the today() or now() functions for the default value too
easy? Or is there a reason for bypassing them for your particular use
case?

Andrew Watt
MVP - InfoPath

On Wed, 17 Nov 2004 11:45:01 -0800, "Help Me" <Help
 
H

Help Me

Infopath will not let me put in today() or now() funcions in to the default
value. It says "Value is not vaild for field type".
 
A

Andrew Watt [MVP - InfoPath]

Click on the fx button to the right of that text box. Then click on
the Insert Function button.

Andrew Watt
MVP - InfoPath
 
H

Help Me

Is that in SP-1 ? I don't have that option...

Andrew Watt said:
Click on the fx button to the right of that text box. Then click on
the Insert Function button.

Andrew Watt
MVP - InfoPath
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top