Skip to main content
stevenm8611492
Known Participant
Oct 25, 2016 12:14 AM UTC
Question

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

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 is closed to new replies. Start a new post to keep the conversation going.

12 replies

try67
Community Expert
Community Expert
Oct 25, 2016 7:35 AM UTC

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.

Translate
stevenm8611492
Known Participant
Oct 25, 2016 10:32 PM UTC

break; removed the second valueAsString, does not work yet

Translate
try67
Community Expert
Community Expert
Oct 26, 2016 7:46 AM UTC

So what are the results?

Translate