I have several combo boxes with the same 3 items in each.
one of the items = "fail"
If one or more combo box's = "fail" I want to pass the value to a text box and for it to remain there until none of the combo box's value = "fail".
I have tried to fix it by adding a second (hiddden) text box where only the item "fail" value is added. The only problem is that if the item "fail is removed from all the combo boxes the value needs to be removed from the text box. How do I do that , am i on the right track?
Cheers for any help
For the custom calculation for the text field:
// array of field names to check
var aFields = ("CheckBox1", "CheckBox2", "CheckBox3");
// clear the field's value
event.value = '';
// loop through the check boxes and test for 'Failed"
for(i = 0; i < aFields.length; i++) {
if(this.getField( aFields[i] ).value == "Failed") {
// set event value to "{Failed"
event.value = "Failed";
} // end match field
} // end loop of check boxes
I Think your right but I can't see where the problem lies!
// custom calculation script for the text field
// array of field names to check
var aFields = ("CheckBox1", "CheckBox2", "CheckBox3");
// clear the field's value
event.value = '';
// loop through the check boxes and test for 'Failed"
for(i = 0; i < aFields.length; i++) {
if(this.getField( aFields[i] ).value == "Failed") {
// set event value to "{Failed"
event.value = "Failed";
} // end match field
} // end loop of check boxes
My Fields are named exactly as quoted! I tried going back to the original code but I now get an error when i copy and paste it!
I see now that there's a different problem. The array is badly defined. It needs to be:
var aFields = ["CheckBox1", "CheckBox2", "CheckBox3"];
Also, I think there's a logical error in your code. Since you want to check if any of the fields has the "Failed" value you should break the loop once you discover that one of them has that value. Otherwise, you're in effect only checking the last field. So your code should actually be:
// array of field names to check
var aFields = ["CheckBox1", "CheckBox2", "CheckBox3"];
// clear the field's value
event.value = '';
// loop through the check boxes and test for 'Failed"
for(i = 0; i < aFields.length; i++) {
if(this.getField( aFields[i] ).value == "Failed") {
// set event value to "Failed" and stop
event.value = "Failed";
break;
} // end match field
} // end loop of check boxes
I didn't know you could do that.
But my problem is still there.
I have two text fields, text field 1 (hidden) has the calculation script and text field 2 poulates via a document leve script as follows:
function Approval()
{
if (!event.willCommit) {
var c = this.getField("Text2");
var f = this.getField("Text1");
switch (event.change) {
case "Fail":
c.value = "Fail";
f.value = "Fail";
break;
case "Minor Deviation":
c.value = "Yes"
break;
case "Observation":
c.value = "Yes";
break;
case " ":
c.value = " ";
}
if (f.value == "Fail"){
c.value = "Fail"
}
}}
I think i probably have the whole thing too complicated! I'd prefer to get rid of the hidden field if possible.
I think i've fixed it based on the calculation order you mentioned.
Basically i've added a calculation to the second text box based on the result of the first text box like this:
if (f.value == "Fail"){
c.value = "Fail"
}else{
c.value = event.value
}
This enbabled me to strip the same information from the document level script.
Phew! Sound like a scripter!
North America
Europe, Middle East and Africa
Asia Pacific