quote:
Originally posted by franck
Hi Richard,
In your OnBeforeChange event (the global one triggered for all checkboxes), prompt the users and to cancel the event if needed use:
e.ReturnStatus = False
Regards,
Franck Dauché
InfoPathDev
Franck,
I am not sure I understand how to do this. I am including a simple sample of what code I have. I have a check box named checkall and two text boxes; dataone and datatwo. If the checkbox is checked dataone and datatwo have 0 inserted. If unchecked blank inserted. Each time the status of the checkbox checkall is changed I want a confirm box to popup. Thanks for any direction you can provide.
Rip
Code Sample:
function msoxd_my_checkall::OnBeforeChange(eventObj)
{
// Write your code here
// Warning: ensure that the constraint you are enforcing is compatible with the default value you set for this XML node.
if (eventObj.Operation == "Insert"){
var mychoice = XDocument.UI.Confirm("Update Fields?", 1);
if (mychoice == 2){
e.ReturnStatus = False;
}
}
}
function msoxd_my_checkall::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;
}
// A field change has occurred and the DOM is writable. Write code here to respond to the changes.
if (eventObj.Operation == "Insert"){
var myzero = "0";
var myblank = "";
if (eventObj.Site.selectSingleNode("../my:checkall").text == "true"){
//Checkbox Unchecked
XDocument.DOM.selectSingleNode("//my:dataone").text = myzero;
XDocument.DOM.selectSingleNode("//my:datatwo").text = myzero;
}else{
//Checkbox Unchecked
XDocument.DOM.selectSingleNode("//my:dataone").text = myblank;
XDocument.DOM.selectSingleNode("//my:datatwo").text = myblank;
}
}
}
Richard T. Henry
Lewisberry, PA, USA
riphenry@gmail.com