This script was written for check-boxes with the same name. Is that the case
in your file?
If not then you can't use it. You will need to write your own script, or
have some who know what they're doing do it for you.
Thanks for the reply,
Yes my checkboxes are all called CheckBox.1, CheckBox.2, CheckBox.3 etc.
Shouldn't that work?
It should... Check the console for error messages and try adding
console.println() commands to debug your code.
I've created a form with 3 fields: CheckBox.1, CheckBox.2 and total-amount
and placed your code as the custom calculation code for total-amount. It
I just realised that I had to actually click in the total-amount field for the sum to appear. Is there any way for the amount to appear and disappear automatically as the checkboxes are ticked or unticked?
It should not be necessary to click the field.
Are you sure you used the custom calculation script?
Are the values of the check-boxes calculated by any other script? If so, you
might have a calculation order problem.
Could I ask just one more related question? I'm using the following script on a button so that a message window pops up:
var cMessage = "To use the website the following must be installed and/or enabled on your computer:
– Macromedia Flash Player plug-in must be installed, (see below)
– One of the following Internet Browsers, (the software you are using to view this page), must be installed:
– On a Windows PC - Internet Explorer 6.0 or later or Firefox 1.5 or later";
var cMyTitle = "my title";
// Display Alert Box with Information Icon
nIcon:3, // Information Icon
nType:0 // Ok Button
The problem is that when I try to exit, I get the error "unterminated string literal".
The error goes away if I remove the line breaks, however I need this type of basic formatting in the dialogue box so that it's more readable.
Is there a way around the error so that I can keep the formatting?
A string can't contain literal line-breaks. If you want to include a line-break in your string you must use an escape character: \n
So, for example:
"This is the first line.\nThis is the second line.";
If you want to actually have line-breaks in your code, to make it more easily readable to you, you need to end the line with a back-slash. Like so:
"This is the first line.\
This is still the first line.\n\
Now it's the second line."
Great - thanks so much again. All solved.
For a calculate script, this line:
this.getField("total-amount").value = nEvalSum;
should be changed to:
event.value = nEvalSum;