Hi,
I have a simple order form with a 'running total' of quantities ordered at the top of the form, calculated thus (FormCalc):
$ = sum(Products.PRODUCT_GROUPS.DATA[*].PRODUCTS.DATA[*].Quantity)
If this quantity is zero (i.e. nothing has been ordered) then I want to prohibit the form being submitted by email. I thought the best way of doing this would be to hide the submit button when this field is zero, and show it when > 0.
I tries appending this code to the same calculate event of this field:
if ( $ > 0 ) then
Button1.presence= "visible"
else
Button1.presence= "hidden"
endif
but no go.
Sorry if this is real simple, but I'd appreciate help!
Thanks.
Solved! Go to Solution.
Views
Replies
Total Likes
When in the code window, you'll see it says something about Ctrl+Click for SOM expression. So if in the event code for one item, you can press Control then click on another item and it will insert the correct reference to it in your code. You have to make sure the focus is in your code when you do it and the mouse cursor will turn into a wide V.
You can right click in the code window and select Check Script Syntax to see if there are any problems.
When viewing the form in Preview, Ctrl+J brings up the JavaScript debugger. It may first need some config in Acrobat. It has been a while since I set that up. Instead of doing app.alert, you can do console.println and it will write to the JavaScript console. Occasionally, you may need to debug something dealing with focus and the app.alert itself affects the focus.
Have you thought about putting your code in a preSubmit event and displaying a message that nothing has been entered? Also do xfa.event.cancelAction = true
Views
Replies
Total Likes
if ( $.rawValue > 0 ) then
Button1.presence= "visible"
else
Button1.presence= "hidden"
endif
Except you probably don't want it in the calculate event. Maybe the change or exit event.
In change:
if (xfa.event.newText > 0 ) then
Button1.presence= "visible"
else
Button1.presence= "hidden"
endif
Views
Replies
Total Likes
Thanks for replying, Steve.
Change event doesn't get called (I put messagebox displays all over the place!), I guess because there is no user input - it's a read only calculate field.
Layout:ready, form:ready and a few others were called so I tried the formcalc code in those but no good.
Tried creating a new text field just so I could use its events, including calculate, changed $.rawValue to TotalQty.rawValue but no good.
This isn't critical, just a nice to have, but I'm really keen to understand better how things hang together. A couple of books
I've seen recommended are winging their way to me now.
Button1 and TotalQty fields are at the same level of the hieerarchy so I think my referencing is OK.
Cheers.
Nigel.
Views
Replies
Total Likes
When in the code window, you'll see it says something about Ctrl+Click for SOM expression. So if in the event code for one item, you can press Control then click on another item and it will insert the correct reference to it in your code. You have to make sure the focus is in your code when you do it and the mouse cursor will turn into a wide V.
You can right click in the code window and select Check Script Syntax to see if there are any problems.
When viewing the form in Preview, Ctrl+J brings up the JavaScript debugger. It may first need some config in Acrobat. It has been a while since I set that up. Instead of doing app.alert, you can do console.println and it will write to the JavaScript console. Occasionally, you may need to debug something dealing with focus and the app.alert itself affects the focus.
Have you thought about putting your code in a preSubmit event and displaying a message that nothing has been entered? Also do xfa.event.cancelAction = true
Views
Replies
Total Likes
Thanks for your time, Steve.
Your preSubmit suggestion works a treat and I'm going to go with that rather than spend any more time on hiding the submit button.
Cheers.
Nigel.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies