Skip to main content
stevenm8611492
Known Participant
October 25, 2016
Question

Problems with searching 60 Fields for String and entering the number 10 into a "BSSB" field; No errors

  • October 25, 2016
  • 12 replies
  • 1046 views

Problems with searching 60 Fields for String and entering the number 10 into a "BSSB" field; No errors

function SetBSMarksmanshipFieldValues() { for (var i = 1; i<61; i++) { var CSki = ("CSk" + ); var CSkStringValue = this.getField(CSki).valueAsString; if (CSkStringValue.valueAsString == "Marksmanship") { this.getField("BSSB").value = 10; i = 60;}}}

if(event.willCommit){if(event.value == "") this.resetForm (["BSSB"]);
else SetBSMarksmanshipFieldValues(event.value);

}

This topic has been closed for replies.

12 replies

try67
Community Expert
Community Expert
October 25, 2016

There are at least two issues with your function. I'll post the code again in a more formatted way, so it's easier to refer to specific lines in it:

function SetBSMarksmanshipFieldValues() {

    for (var i = 1; i<61; i++) {

        var CSki = ("CSk" + );

        var CSkStringValue = this.getField(CSki).valueAsString;

        if (CSkStringValue.valueAsString == "Marksmanship")

            { this.getField("BSSB").value = 10; i = 60;}

    }

}

Line 6: Minor issue. That is not a good way of breaking out of a loop. Use the "break" command instead.

Line 5: Major issue: You've already defined CSkStringValue as the string value of the field, so there's no need to access this property once more.

stevenm8611492
Known Participant
October 25, 2016

break; removed the second valueAsString, does not work yet

try67
Community Expert
Community Expert
October 26, 2016

So what are the results?