I have two radio button lists laid out in two columns to select garment sizes (small, medium, large). The "M" side is MEN and the "W" side is WOMEN. The Radio button lists are named MENS and WOMEN respectively.
ITEM QTY. COST ITEM QTY. COST
||MS ||WS
||MM ||WM
||ML ||WL
||NO SELECTION ||NO SELECTION
______ ______
TOTAL TOTAL
The user selects the size using the radio button, moves into the QTY field to input the quantity and the COST is automatically calculated in a read-only numeric field (the QTY and COST fields are not shown above).
However, if a radio button (other than "NO SELECTION") is selected in one list and you attempt to select something in the OTHER list, after inputting a quantity a message box will pop up saying: “Unable to calculate totals. You have an active selection in the other side. Please set the other side to 'No Selection' to continue." The event used for this in the QTY field is "exit".
Additionally, the fields are reset to zero (0) making the TOTAL zero (0).
The "NO SELECTION" button of each list has a value of 1.
I have a formcalc script in each of the QTY fields on the mens side that read:
if (Women > 1) then
xfa.host.messageBox("Unable to calculate totals. You have an active selection in Women. Please set
Women to 'No Selection' to continue.")
MS=0
MM=0
ML=0
endif
The WOMEN side has a similar formcalc script if something is selected on the MENS side. It works fine in formcalc. However, when I try to use Javascript to perform this, the message box does not appear.
if (Women > 1) {
xfa.host.messageBox("Unable to calculate totals. You have an active selection in Women. Please set
Women to 'No Selection' to continue.");
MS=0;
MM=0;
ML=0;
}
I am teaching myself JS and wanted to put functions into the project since this is all repetitive. However, I don't understand why it works with formcalc and not JS. The book I purchased for learning JS was a bad choice (and I won't mention it here). However, any help would be apppreciated.
BTW, I used UPPER CASE in this post for emphasis. The case matches in the actual script.
Views
Replies
Total Likes
In FormCalc the default property for an object is the rawValue so when you want to get what the user entere
d for a field you can use just the objectName. In Javascript that does not exist so you have to explicitally ask for the rawValue property to get what the user entered. So your code woudl look like:
if (Women.rawValue > 1) {
xfa.host.messageBox("Unable to calculate totals. You have an active selection in Women. Please set
Women to 'No Selection' to continue.");
MS.rawValue=0;
MM.rawValue=0;
ML.rawValue=0;
}
Assuming MS, MM and ML are fields and not javascript variables.
Paul
Views
Replies
Total Likes
Paul, will this script work, instead?
var brain
var correctSyntax = "Object.rawValue"
if (correctSyntax != "Object.rawValue") {
xfa.host.messageBox("YOU ARE AN IDIOT!);
brain = ""
}
Learning Javascript is gonna be a loooong process for me
But as they say, if you don't make mistakes, how will you learn? I'm glad there are guys like you around.
THANKS, PAUL!
Views
Replies
Total Likes
Yes I do not see why that won't work .....except that you have to close your quote for the string YOU ARE AN IDIOT! You are just using standard javascript it gets more fun when you start mixing in form objects For example if the string correctSyntac was coming from a field called TextField1 on your form instead of a defined variable then your code woudl be:
var brain
if (TextField1.rawvalue != "Object.rawValue") {
xfa.host.messageBox("YOU ARE AN IDIOT!);
brain = ""
}
The message woudl only appear of the user entered the chars Object.rawValue into the field. Note that these comparisons are case sensitive.
Hope that helps
Paul
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies