Hi S.Y.M. Wong-A-Ton, I could follow your instrauctions to step 11 ok. I was
not confident adding the extra line of code but did what you said. my code
for start and end time now looks like:
/*
* This file contains functions for data validation and form-level events.
* Because the functions are referenced in the form definition (.xsf) file,
* it is recommended that you do not modify the name of the function,
* or the name and number of arguments.
*
*/
// The following line is created by Microsoft Office InfoPath to define the
prefixes
// for all the known namespaces in the main XML data file.
// Any modification to the form files made outside of InfoPath
// will not be automatically updated.
//<namespacesDefinition>
XDocument.DOM.setProperty("SelectionNamespaces",
'xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-01-24T23:21:32"');
//</namespacesDefinition>
//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
// This function is associated with the following field or group (XPath):
/my:myFields/my:timeEntries/my:timeEntry/my:startTime
// Note: Information in this comment is not updated after the function
handler is created.
//=======
function msoxd_my_startTime::OnAfterChange(eventObj)
{
// Write code here to restore the global state.
if (eventObj.IsUndoRedo)
{
// An undo or redo operation has occurred and the DOM is read-only.
return;
}
updateFields(eventObj.Source);
}
// A field change has occurred and the DOM is writable. Write code here to
respond to the changes.
}
//=======
// The following function handler is created by Microsoft Office InfoPath.
// Do not modify the name of the function, or the name and number of
arguments.
// This function is associated with the following field or group (XPath):
/my:myFields/my:timeEntries/my:timeEntry/my:endTime
// Note: Information in this comment is not updated after the function
handler is created.
//=======
function msoxd_my_endTime::OnAfterChange(eventObj)
{
// Write code here to restore the global state.
if (eventObj.IsUndoRedo)
{
// An undo or redo operation has occurred and the DOM is read-only.
return;
}
updateFields(eventObj.Source);
}
// A field change has occurred and the DOM is writable. Write code here to
respond to the changes.
}
If I try to Preview the Form at this stage I get the following error message:
nfoPath cannot open the selected form because of an error in the form's code.
The following error occurred:
Syntax error
File:script.js
Line:37
At step 16 I am also confused. I could not down load the JScript File. It
would not open. Do I just copy the code you wrote in step 16. If so then
where do I copy it to? Does it go into totalHours? Sorry to keep hounding you
but I am out of my league when we get into code. Thanks Geoff
> If I try to Preview the Form at this stage I get the following error message:
> nfoPath cannot open the selected form because of an error in the form's code.
[quoted text clipped - 3 lines]
> File:script.js
> Line:37
I see a closing curly bracket ( } ) too many in your code, which might be
causing the script error. :) You had to only add
updateFields(eventObj.Source); to the OnAfterChange event.
> At step 16 I am also confused. I could not down load the JScript File. It
> would not open.
I zipped up the JScript file. If you have WINZIP or are working on WinXP,
you should be able to open it.
> Do I just copy the code you wrote in step 16. If so then
> where do I copy it to? Does it go into totalHours?
Yes. Paste it just below the last closing curly bracket ( } ) in your code.
And no, it does not go into totalHours. Actually, you do not have to create
an OnAfterChange event for totalHours.
> Sorry to keep hounding you
> but I am out of my league when we get into code.
That's okay. Here's what you can do: Since I don't publish my email
addresses (due to spamming), you can Google my name, click on the first link
that appears, go to the "Contact" page on that site, and send me a message
from there. I'll try and help you get the form working or send you a working
sample.
---
S.Y.M. Wong-A-Ton