I'm having multiple issues here.
form1.MembershipRenewalAppForm.MembershipTypeGroup.MemberTypechkGroup.chkMST-NRM::initialize - (JavaScript, client)
if (this.rawValue == true){
chkMST-RFP.presence = "invisible"
chkMST-ARC.presence = "invisible"
chkMST-Corp.presence = "invisible"
}else {
chkMST-RFP.presence = "visible"
chkMST-ARC.presence = "visible"
chkMST-Corp.presence = "visible"
}
form1.MembershipRenewalAppForm.MembershipTypeGroup.MembershipValueGroup.MT15::initialize - (JavaScript, client)
if (chkMST-NRM.rawValue == true)
this.rawValue = 15;
else
this.rawValue = 0;
form1.#subform[1].DriverClassesGroup.DCSub::calculate - (JavaScript, client)
// Set the field properties.
if (DriverClassesGroup.rawValue > 1)
this.rawValue = chkMST-ARC.rawValue * DriverClassesGroup.rawValue - chkMST-ARC.rawValue;
else
this.rawValue = 0;
form1.#subform[1].SumBalance::calculate - (JavaScript, client)
this.rawValue = MT15.rawValue + MT20.rawValue + MT00.rawValue + DCSub.rawValue;
form1.#subform[1].ResetButton1::click - (JavaScript, client)
xfa.host.resetData();
MemberID.presence = "invisible"
I'm attaching both the link to the form and the file itself for anyone who may be generous enough to help in this. I would be greatly appreciative in getting this resolved.
Thanks in advance,
D
Solved! Go to Solution.
Views
Replies
Total Likes
Sorry you want to click th echeckbox and fire the change event on the checkbox (that is where you should have added the code to update the field). To do that add this code:
Or you can simply update the MT10 field directly.
Paul
Views
Replies
Total Likes
Sorry, I just relized I may need clarification on problem 2.a the script shown.
This line:
(DriverClassesGroup.rawValue > 1)
is meant to be if more than one checkbox in DriverClassesGroup is selected, calculate, otherwise the value is $0.00.
Views
Replies
Total Likes
D, there are lots of little problems in here. Have you made any headway or changes to the form since you last posted it?
Views
Replies
Total Likes
No, not in the least. I've made no headway at all since posting this. Did I really mess up badly?
Thanks for your attention,
D
Views
Replies
Total Likes
I looked at your form and have modified it (see the attachment). There are three fundamental problems that you ran into.
1. The location of the objects that you are addressing in the script relative to the object that is calling the script. If you look at the hierarchy it acts very mush liek a file system with directories in files. If you want to address a file from another directory you must path to it. It is the same for objects in the hierarchy. As a quick shortcut (and to save you from typing long path names) in the script editor place the cursor where you want the expression to go. Now hold down the Ctrl key and move the mouse to the field that you want to address on the canvas. The cursor will change to a V. Once on the field click the mouse and it will put the relative expression into the script editor. Now you can add th emethod or property you want to address. Note that in a few cases you were trying to check the status of a group object. That has no value, it is simply for ease of design.
2. The event model needs to be understood a little better. You had most of your code on the Initialize event. That event will only fire once when the form is loaded. So any changes the user makes will not even fire the code. On the checkboxes I moved your code to the change event. That means that each time the checkbox changes (on/off) the script will run. On the fields, the code runs on the calculate event. That means the the event will fire each time the form loads and each time a field named in the script changes. So when the user picks a class the subtotal will update with current information.
3. The logic for checkboxes that make up the classes was flawed. I changed it to add a field to hold the number of checkboxes that were checked. Then I added code to each checkbox to update the field by 1 when it was checked and decrement the counter by 1 when unchecked. This field should be hidden from the user. I left it visible so you can see it and how it works. Because this field is named in the Total calc it will update the total each time you choose a checkbox.
Paul
Views
Replies
Total Likes
Paul, Thanks for your time. I'm just having one problem. The dollar amounts are not changing. If I check off Non Racing Membership the three bellow go invisible, which is great, and it's corresponding textfield is giving a value of $15.00. If I uncheck it the three bellow reappear, which is great, but I'm still not getting the monetary value in the textfields to their left.
At the bottom for the classes, the counter works fine, but I'm not seeing the dollar amount being calculated, which I'm ecpecting to be because the textfield it is needing the multiplied value from (MT10) is not changing from $0.00.
Views
Replies
Total Likes
I didn't add the code for that. I did it on the 1st checkbox to show you how and figured you could add the appropriate code to the others.
Paul
Views
Replies
Total Likes
I tried Editing my reply above but it wouldn't let me,Permission denied".
Sorry, I found what needed to me changed But I'm realizing that once additional classes are check, I need confirm that MT10 has a value of 10 and if not, I need chkMST-ARC == true only if more than one class is chosen. How would I write that if statement and where would I apply it?
Thanks for your attention,
D
Views
Replies
Total Likes
You could add to each of the class checkboxes:
chk-MST-ARC.rawValue = 1
That will check the checkbox on, this causing the MT10 field to update, or you can simply update the MT10 field directy:
MT10.rawValue = 10
You shoudln't have to check its value as you are setting it to the same value .....so simply set it rather than checkit
Paul
Views
Replies
Total Likes
I tried applying the line as you said to the classes checkboxes i believe you mean. Nothing is calculating now. Here is the script:
form1.#subform[1].DriverClassesGroup.SmallTruckGroup.Classes[0]::change - (JavaScript, client)
if (this.rawValue == "1"){
NoClassesSelected.rawValue = NoClassesSelected.rawValue + 1;
chkMST-ARC.rawValue = 1
} else {
NoClassesSelected.rawValue = NoClassesSelected.rawValue - 1;
}
I know that is wrong, you said earlier that I need to specify the "path?" I think.
Views
Replies
Total Likes
Use the technique I described earlier where you have Designer determine the path. Put your cusror in the script editor wher yo uwant the expression to appear. Then hold the ctrl key down and drag the mouse onto th eobject you want to address. The cursor wil lchange to a V. Then click and the proper expression relative to th eobject that is running the script will appear in the script editor.
Paul
Views
Replies
Total Likes
I don't recommend using '-' as part of an object name. Javascript interprets chkMST-ARC as 'chkMST minus ARC'. That's why you need to surround those object references with xfa.resolveNode("object") while others don't require it. It is helpful to use Paul's technique since Designer knows when that's necessary.
Also, don't forget the semicolons at the end of your statements:
xfa.resolveNode("chkMST-ARC").rawValue = 1;
Views
Replies
Total Likes
Gentelmen thank you, with each bit of help I get from you, I come a little closer to uderstanding Designer better. Yes, I've followed the path technique and found the DCSub and the NoClassesSelected were not calculating. I hacked my way through by comparing what was done in chkMST-NRM and found that I needed something more so before the "=" I typed "." and scrolled through the options privided. Nothing seemed right to me except for setAtribute so I gave that a try. The NoClassesSelected counts the number of classes chosen, but still does not set chkMST-ARC as checked. I'm thinking that instead of "1" I need either "true" or "On", but when I tried that the DCSub was not calculation because chkMST-ARC was not setting. Here is what I have:
form1.#subform[1].DriverClassesGroup.SmallTruckGroup.Classes[0]::change - (JavaScript, client)
if (this.rawValue == "1"){
NoClassesSelected.rawValue = NoClassesSelected.rawValue + 1;
xfa.resolveNode("MembershipRenewalAppForm.MembershipTypeGroup.MemberTypechkGroup.chkMST-ARC").setAttribute = 1;
} else {
NoClassesSelected.rawValue = NoClassesSelected.rawValue - 1;
}
Once I manually check chkMST-ARC the form works as it should, but if it's not checked and additional classes are chosen... chkMST-ARC does not set.
Views
Replies
Total Likes
I'm just now seeing Kevin's post so let me try adding .rawValue in place of .setAttribute. I'll post my result in a moment.
Views
Replies
Total Likes
Gentlemen, thanks for your help. I am yet another step closer to success.
form1.#subform[1].DriverClassesGroup.SmallTruckGroup.Classes[0]::change - (JavaScript, client)
if (this.rawValue == "1"){
NoClassesSelected.rawValue = NoClassesSelected.rawValue + 1;
xfa.resolveNode("MembershipRenewalAppForm.MembershipTypeGroup.MemberTypechkGroup.chkMST-ARC").rawValue = 1;
} else {
NoClassesSelected.rawValue = NoClassesSelected.rawValue - 1;
}
chkMST-ARC is now setting as if checked. However, I'm not seeing MT10 receiving a value once chkMST-ARC is set as checked. Should I add a line to put the value into MT10 just as chkMST-ARC is being set as checked, or once chkMST-ARC is set as shecked, should that trigger the change state and cause chkMST-ARC to put the value 10 to MT10?
Views
Replies
Total Likes
Just realized that you are setting the checkbox programmatically then the calc event will not fire .....so you can fire it yourself. After you set the checkbox do this command:
MT10.execCalculate();
Paul
Views
Replies
Total Likes
OKay, just had time to try out the calculate(). It didn't work. I tried applying it to chkMST-ARC, no go. I tried applying it to MT10, no go. I tried applying it to each of the classes, no go. I also tried using the path technique, still no go. Please help.
Views
Replies
Total Likes
Sorry you want to click th echeckbox and fire the change event on the checkbox (that is where you should have added the code to update the field). To do that add this code:
Or you can simply update the MT10 field directly.
Paul
Views
Replies
Total Likes
Excellent! Thanks for all your trouble and time.
Form works great!
Views
Replies
Total Likes
Sorry, forgot... The reason that I choose not to rely on updating manually is simply because out of more than 350 million people, there's bound to be a few that may apply to our organization and not check off Additional Racing Classes and then submit the incorrect fee with the membership application. This avoids that mistake.
Thanks again,
D
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies