Copy link to clipboard
Copied
I have a CheckBox36 and a Text28 box. If checkbox36 is "checked" then text28 is populated with a specific numeric value "100". I am using this action in checkbox36 properties: event.value = this.getField("Text28").value = "100"; this works great.
How do make "Text28" have "0" value when i "uncheck" checkbox36?
Copy link to clipboard
Copied
THANK YOU!! it works now. I had to correct the spelling of the name of my Check Box - then it worked. Thank you for being patient with me.
Copy link to clipboard
Copied
You need to use the "if ... them ... " conditional statement to test the value of the check box and then execute the block of code base on the value.
Since the value of the check box is "Off" when not checked, I would test for that value. When "Off" the text field is set to zero if not "Off" the text field is set to 100.
Copy link to clipboard
Copied
Your code is not correct. You should use this code as the custom calculation script of the text field:
event.value = (this.getField("checkbox36").valueAsString=="Off") ? 0 : 100;
Copy link to clipboard
Copied
thank you for your help; but it did not work as desired.
I entered the code you gave in the custom calculation script of the text field of textbox28. Then i previewed my form. I checked checkbox36 and 100 came up in text28. that is what i want. But when I uncheck checkbox36, the 100 still did not go away in text28.
Do i need to remove the code I had in checkbox36? It is event.value = this.getField("Text28").value = "100";
Copy link to clipboard
Copied
Remove this code.
Copy link to clipboard
Copied
Open the JavaScript console, <Ctrl> + J, and see if there are any messages. This may provide a hint as to what the problem is.
JavaScript is case sensitive an fields must be spelled as they are named.
You can try the following code in the custom calculation for the Texxt28 field:
try {
if(this.getField("CheckBox36").value == "Off") {
event.value = 0;
} else {
event.value = 100;
}
} catch(error) {
console.show();
for(var i in error) {
console.println(i + ": " + error) + " " + error.i;
}
console.println("exitMessage: " + error.extMessage);
console.println("message: " + error.message);
console.println("name: " + error.name);
if(this.getField("CheckBox36") == null) {
console.println("Error in field name");
}
}
Copy link to clipboard
Copied
I placed the new code you gave me in Text28. I goth the following syntax error:
catch without try 7: at line 8
what does that mean? i don't know how to fix that...
thank you again for your help
Copy link to clipboard
Copied
this was highlighted when i got the syntax error:
console.show();
Copy link to clipboard
Copied
Are you sure you copied the entire code? Copy it from here:
try {
if (this.getField("CheckBox36").value == "Off") {
event.value = 0;
} else {
event.value = 100;
}
} catch(error) {
console.show();
for(var i in error) {
console.println(i + ": " + error) + " " + error.i;
}
console.println("exitMessage: " + error.extMessage);
console.println("message: " + error.message);
console.println("name: " + error.name);
if (this.getField("CheckBox36") == null) {
console.println("Error in field name");
}
}
Copy link to clipboard
Copied
THANK YOU!! it works now. I had to correct the spelling of the name of my Check Box - then it worked. Thank you for being patient with me.

