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
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Drop down filling short cuts

carojvi
Level 2
Level 2

Hello,

I am building a form with drop down boxes. These are ued to answer questions with Yes, No and N/A. I would like the end user to be able to tab to the next drop down and type either a number or a letter as a shortcut to fill out the boxes (vs. having to click). For example type in 1 for yes, 2 for no, 3 for N/A...

Can I do that and how?

Thank you,

Caroline

1 Accepted Solution
Steve_L_Walker
Correct answer by
Level 10
Level 10

Yes you can.

Here's how.

1) Allow custom text entry on the drop-down list.

p2.png

2) On the binding tab, select 'Specify Item Values'. By default when you click 'Specify Item Values' Designer will add values starting with 1. Since I added the List Items in the order 'Yes', 'No', 'N/A' they are assigned 1, 2, 3.

p3.png

Now a user can enter a value into the field and the respective text value will appear. For example, enter '1' and 'Yes' appears.

Probably a good idea to add some validation to each drop-down so only 1, 2, or 3 can be entered. For example....

// form1.page1.subform1.q1::exit - (JavaScript, client)


if (!(this.rawValue == 1 || this.rawValue == 2 || this.rawValue == 3)) {

  xfa.host.messageBox("The answer must be 1 - Yes, 2 - No, or 3 - N/A");

}

Steve

View solution in original post

6 Replies
Steve_L_Walker
Correct answer by
Level 10
Level 10

Yes you can.

Here's how.

1) Allow custom text entry on the drop-down list.

p2.png

2) On the binding tab, select 'Specify Item Values'. By default when you click 'Specify Item Values' Designer will add values starting with 1. Since I added the List Items in the order 'Yes', 'No', 'N/A' they are assigned 1, 2, 3.

p3.png

Now a user can enter a value into the field and the respective text value will appear. For example, enter '1' and 'Yes' appears.

Probably a good idea to add some validation to each drop-down so only 1, 2, or 3 can be entered. For example....

// form1.page1.subform1.q1::exit - (JavaScript, client)


if (!(this.rawValue == 1 || this.rawValue == 2 || this.rawValue == 3)) {

  xfa.host.messageBox("The answer must be 1 - Yes, 2 - No, or 3 - N/A");

}

Steve

View solution in original post

carojvi
Level 2
Level 2

Awesome, thank you!

I'm not familiar with the validation process/script. Would I be pasting this code somewhere and where?

Thanks!

Caroline

Steve_L_Walker
Level 10
Level 10

Caroline,

Script can be applied to an event on an field through the Script Editor.

1) Go to the Script Editor. If the Script Editor is not visible it can by toggled on through the toolbar Window > Script Editor or Shift + Ctrl + F5.

2) Highlight the field you want the script applied to, in this case 'q1'.

3) Since we want the validation script applied to the exit event (meaning the script will fire when focus leaves the field), open the 'Show' drop-down and select the 'exit' event.

4) Designer supports scripting in JavaScript and FormCalc. Since the script being applied is JavaScript make sure the Language selected is JavaScript. This may or may not be your default scripting language.

5) Since we want the script to execute on the client make sure Run At is set to Client. This may or may not be your default execution setting.

6) Add the script.

p2.png

Steve

carojvi
Level 2
Level 2

Thank you. It works, if I enter 6 for example I get the error message; however, my "6" stays in the box when I close the message and tab out. Is this supposed to happen?

Steve_L_Walker
Level 10
Level 10

Yes.

You can amend the script to remove the value entered using this.rawValue = "";

// form1.page1.subform1.q1::exit - (JavaScript, client)


if (!(this.rawValue == 1 || this.rawValue == 2 || this.rawValue == 3)) {

  xfa.host.messageBox("The answer must be 1 - Yes, 2 - No, or 3 - N/A");

  this.rawValue = "";

}

carojvi
Level 2
Level 2

Perfect, thanks so much for your help!

Caroline