This will get you the value:
The value itself depends on how you set it up. It can be "Off"/"On", "Yes"/"No", or something like that.
Thanks you so much. The answer was obvious (that is, after you said it). So, likewise, I would guess. Let's say that I established the return value as "Yes" when I created the check box. That means that I can switch it off if I set the value getField("CB1").value=="No".
No neccsarily. I think the default value when the button is not checked is
But that might depend on your version and settings.
Thanks for your valuable time. I am stuck with this item. Please, consider the following code:
var dblTotalParts = 0;
this.getField("AllParts").value = 0;
var i = 0;
while( i < 16 )
strCheckBox = "CB" + i; //that will result in strCheckBox = "CB0" trough CB15
strItemLine = "LT" + i; // Same with this other field. But this seems to be working
dblLineValue = this.getField(strItemLine).value;
flgCBStatus = this.getField(strCheckBox).value; // Message I get "this.getField(strCheckBox) has no properties"
if(dblLineValue > 0)
// if(flgCBStatus == "Yes")
dblTotalParts = dblTotalParts + dblLineValue;
if(dblTotalParts > 0)
this.getField("AllParts").value = dblTotalParts;
// End of procedure
I defined the CheckBox (which are labeled CB0 trough CB15 in the form) to return the value "Yes".
I need the loop to find the status of every line in the form. I would appreciate any comment on it. Also, I changed the CB so it would return "ON" instead of Yes as originally set up,but it does not make any difference.
Thanks in advance.
You need to check your field names. It seems there's a problem there.
Add a console.println line to debug which field causes the problem.
In addition, this line (probably) won't work:
if(dblLineValue > 0)
You need to convert the field's value to a proper number (it's usually a
String) in order to compare it to 0 in that way. You can multiple if by 1,
or use the new Number() function to do that.
I want to cheerfully thank you for your support. You gave me excelent leads that helped me to get the answer.
The check box, I found, can be assigned a return value. In my case it was "Yes". If you don't the default return is "On" and, in any case if it is not checked, the return value is always "Off".
You were right also when you sent me to review the names of the check boxes. It turned out that the last two check boxes were name CB14, instead of CB14 and CB15. So, when the loop reached the last one it trigger an error since it was name CB14 instead of CB15. Simple bug but powerful enough to keep me up to 3 o'clock in the morning.
Lastly. The line that you think it probably won't work because it may be returning a string as oppossed to a numeral value, actually works, because the field was formatted as a number and this is what it returns.
I decided to inform you about the whole thing, basically because I felt that is good to have feed back. You definetively helped me. Secondly, I wanted to share my small finding in case you can use it.
Thanks, and I'm glad to hear you were able to solve it...