Special submit code...almost figured out!!

J

Jeffshex

I have to thank Greg C. so far for getting me to where I curretnly am, but I
need help on one more issue. The code below works for the most part. When
you click submit it checks the 35 and if it is less it does go to the prompt
and ask. Where I need the help is, if you click the yes OR no button, it
still submits. I guess I need some advice on some code to return to the form
if no is clicked.

function CTRL186_7::OnClick(eventObj)
{
// Submit code
if(parseInt(XDocument.DOM.selectSingleNode("//my:WeekTotal").text) <= 35)
XDocument.UI.Confirm("Your week total is under 35 hours. Do you wish to
continue?", 4);
XDocument.Submit();
XDocument.UI.Alert("Your status report has been submitted successfully.");
Application.ActiveWindow.Close();
}

If you know what I am misssing please help!
Thanks!!
 
J

Jeffshex

I am still unsure of how to do that. This is the layout of the code. Some
of its for real and some i just can't find the syntax so i'm needing help.
This sounds like it should be pretty easy, but i'm a novice at this and need
the details explained to me.
Thanks again!

{
// Submit code
if(parseInt(XDocument.DOM.selectSingleNode("//my:WeekTotal").text) <= 35)
XDocument.UI.Confirm("Your week total is under 35 hours. Do you wish to
continue?",yes);
if (yes)
XDocument.Submit();
XDocument.UI.Alert("Your status report has been submitted successfully.");
Application.ActiveWindow.Close();
else
return to the form for changes
else
XDocument.Submit();
XDocument.UI.Alert("Your status report has been submitted successfully.");
Application.ActiveWindow.Close();
}
 
J

Jeffshex

I got this to work so far. It still submits everything and seems to work
properly, but after it submits there still pops up a message box saying that
there was an error. Otherwise it works fine.

function CTRL186_7::OnClick(eventObj)
{
// Submit code
if(parseInt(XDocument.DOM.selectSingleNode("//my:WeekTotal").text) >= 35)
{XDocument.Submit();
XDocument.UI.Alert("Your status report has been submitted successfully.");
Application.ActiveWindow.Close();}
if(parseInt(XDocument.DOM.selectSingleNode("//my:WeekTotal").text) <= 35)
var clicked = XDocument.UI.Confirm("Your week total is under 35 hours. Do
you wish to continue?",4);
if (clicked==4)
{XDocument.Submit();
XDocument.UI.Alert("Your status report has been submitted successfully.");
Application.ActiveWindow.Close();}
}
Let me know if you have any ideas!
 
J

Jeffshex

I take that back...the confirm box still doesn't do anything whether you
click yes or no.
this is starting to get out of control. please help.
 
J

Jeffshex

Yes, that helps big time. Say for instance I chose to go with the OK/Cancel
confirm box, how do you call what button was selected? I know Ok returns the
value of "1" and Cancel returns "2". Would it be like:
{
if (XdConfirmChoice=1)
XDocument.Submit();
XDocument.UI.Alert("Your status report has been submitted successfully.");
Application.ActiveWindow.Close();
else if (XdConfirmChoice=2)
return;
}
Or do I need to refer to those as xdOk and xdCancel?
That section didn't really describe how to call on those "enumerators".

Greg Collins said:
You need to look up how Confirm() works in the InfoPath help. Do the following:

1. From InfoPath, Press F1.
2. In the InfoPath Help task pane, click Table Of Contents under the search box.
3. Click InfoPath Developer's Reference at the end of the table of contents.
4. Click InfoPath Object Model Reference.
5. Click Methods.
6. Click Confirm Method.

This explains the Confirm() method and how to use it. But just as importantly, it has links that explain XdConfirmChoice (which is the value you get back from the confirm dialog box), and XdConfirmButtons (which are the values you use to display different button sets on the confirm dialog box).

I hope this helps.

--
Greg Collins [InfoPath MVP]
Please visit: http://www.InfoPathDev.com



I take that back...the confirm box still doesn't do anything whether you
click yes or no.
this is starting to get out of control. please help.

Jeffshex said:
I got this to work so far. It still submits everything and seems to work
properly, but after it submits there still pops up a message box saying that
there was an error. Otherwise it works fine.

function CTRL186_7::OnClick(eventObj)
{
// Submit code
if(parseInt(XDocument.DOM.selectSingleNode("//my:WeekTotal").text) >= 35)
{XDocument.Submit();
XDocument.UI.Alert("Your status report has been submitted successfully.");
Application.ActiveWindow.Close();}
if(parseInt(XDocument.DOM.selectSingleNode("//my:WeekTotal").text) <= 35)
var clicked = XDocument.UI.Confirm("Your week total is under 35 hours. Do
you wish to continue?",4);
if (clicked==4)
{XDocument.Submit();
XDocument.UI.Alert("Your status report has been submitted successfully.");
Application.ActiveWindow.Close();}
}
Let me know if you have any ideas!
 

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