Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Using setFocus from a SWITCH statement

Avatar

Level 4

Hi

Im trying to have my switch selections do a couple of things from one selection and am getting stuck on the correct syntax to use

below is a code example of what i'm trying to do - but basically i need a selection case "2" say, to (1) set various fields values from variables (2) set the focus event to a field (that relates to the choice)

here's an example of my (broken) code (orange below) - does anyone know the correct syntax for doing this? The field i want to force the focus/view to go to in a couple pages down (if that makes a difference)....

thanks

switch (this.rawValue) {

     case "8":

{cHist.presence = "visible";}

          break;

case "1":{

(page3.para1.rawValue = a1.value)

(page3.para2.rawValue = b1.value)

(page3.target.presence = "visible")

(xfa.host.setFocus(page3.target)

}

// the idea being to make the field visible then take the users focus to it once the variables have been set - i hope switch can do multiples and it's just my syntax (again) -- thanks for the help

         break;

case "2": {

(page3.para1.rawValue = a1.value)

(page3.para2.rawValue = b2a.value + ", which occured in " + page5.oneEBA.rawValue + ")." + b2b.value)

}

1 Accepted Solution

Avatar

Correct answer by
Level 10

xfa.host.setFocus(page5.oneEBA);

View solution in original post

0 Replies

Avatar

Level 10

The case does not use braces "{}". See https://developer.mozilla.org/En/Core_JavaScript_1.5_Guide:Conditional_Statements

Try

switch (this.rawValue) {

     case "a":

          expression;

          expression;

          ...

          break;

     case "b":

          expression;

          ....

          break;

     default:

          break;

}

Steve

Avatar

Level 4

thanks steve,

it seems to accept this syntax:

case "5":

page3.para1.rawValue = d1.value + " " + page2.datedisqual.rawValue + "in the " + page2.courtdisqual.rawValue + " District Court";

page3.para2.rawValue = d3.value;    

xfa.host.setFocus.page5.oneEBA;

}

but the setFocus event is having no effect -- no sure why (I suspect it's failing silently for some reason.... or can focus not be set multi pages down?)
thanks

Avatar

Correct answer by
Level 10

xfa.host.setFocus(page5.oneEBA);

Avatar

Level 4

Hi steve,

thanks for the hep earlier, i just have one other (hopefully simple question, if you can spare a few minutes) - namely can you/how do you attach a switch statement to a field (exit event) that uses the rawvalue of another dropdown list to determine what to do (another syntax issue i guess)...

here's my issue/code:

  switch (worktype.rawValue)

case "1": {

page3.para5.rawValue = f1 + this.rawValue +".";

}

         break;

case "2": {

page3.para5.rawValue = f1 + this.rawValue +"222222.";

}

        break;

case "3": {

page3.para5.rawValue = f1 + this.rawValue +"3333";

}}

// this code being attached to a different field than worktype....
thanks for all the help, it's a greta help to the newbies