Hello!
This is my first attempt at creating a form in LiveCycle and it happens to be a complex one spanning 10 pages.
I am having problems with scripting a few things - all of which I am basing my script on information I have found in the forum, how to, etc.
1. Hide a radio button based on a previous number field entry.
The second page of my form, I have a pricing table that has a Rush Service listed. It has the associated fields of Qty and Amount.
Two rows below that, is the shipping method which is set up with two radio buttons inside a subform. The radio buttons are named Priority and Express.
I am trying to have it so that if a person enters "1" into the Qty box for the Rush Service, that only the Express radio button is visible.
I put this code in the exit for the Qty field:
if ($.rawValue == 1) then form1.Page2_Subform.Pricing_Subform.Pricing_Table.Row13.Shipping_Subform.Shipping.Priority.presence = "hidden" form1.Page2_Subform.Pricing_Subform.Pricing_Table.Row13.Shipping_Subform.Shipping.Express.presence = "visible" else form1.Page2_Subform.Pricing_Subform.Pricing_Table.Row13.Shipping_Subform.Shipping.Priority.presence = "visible" form1.Page2_Subform.Pricing_Subform.Pricing_Table.Row13.Shipping_Subform.Shipping.Express.presence = "visible" endif
I don't get any errors when I preview the form but nothing happens when I enter the 1 into the Qty field.
2. Using setFocus to keep focus on a required field.
I noticed that when I set a field to required, nothing happens if you don't enter anything. So I found an articles that addressed this issue which seemed to be a simple solution.
I added this code under the validate for the Name field:
if(form1.Page2_Subform.AddressBlock.AddressTable.Row1.Name.rawValue eq null) xfa.host.setFocus("xfa.form1.Page2_Subform.AddressBlock.AddressTable.Row1.Name.rawValue") endif
I get a syntax error near the xfa.
3. How do I set up a field so that a person can only enter a "0" or "1"?
4. Make sure the number is negative
Within my pricing table, I have a discount a person can manually enter. I want to make sure that the number entered is negative so that it properly subtracts from the total. I'm not sure where to begin with this one.
enusures amy number entered will be negative
#3 not sure but check boxes serve the same function
#2 not positive but i would guess that it is about the .rawValue part
#1 Well its hard to say what your doing but you might want to look into a check box and i think to hide a radio button then you have to hide both since inorder for them to work prpoerly ie radio button you want to see both and they have the same name. Maybe check box again.
As for your script well not an expert i am new also but it looks like your mixing java script and formcalc $ is a formcalc operation but presences is a javascript dont quote me but i think thats the begining of the issuse also i would guess that this script should be placed in the change event state and have you checked the initial state of the object? Not sure if any of this helps but sounds like you have done alot good luck