Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Make a drop-down list option unselectable

New Here ,
Mar 20, 2021 Mar 20, 2021

I am attempting to make a few options in a dropdown list UNSELECTABLE by the end-user in a PDF. The unselectable options are actually the Cause of Death categories - we only want the users to select the actual conidtion and not select the category accidently.

Example below:


Hemorrahge (display in dropdown, but make it unselectable)

  10.1 Hemorrhage - Uterine Rupture

  10.2 Placental Abruption

  10.3 Placenta Previa

  ... etc

Infection (display in dropdown, but make it unselectable)

  20.1 Chorioamnionitis

  20.2 Sepsis

  ... etc

 

Any help would be greatly appreciated. Thank you,

GC

TOPICS
Create PDFs , How to , JavaScript , PDF forms
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
1 ACCEPTED SOLUTION
Community Expert ,
Mar 20, 2021 Mar 20, 2021

Try this version of the code:

 

if (event.value) event.rc = /^\d/.test(event.value) || event.value==event.target.defaultValue;

View solution in original post

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 20, 2021 Mar 20, 2021

Add this code as the field's custom validation script:

 

if (event.value) event.rc = /^\d/.test(event.value);

 

This will only allow the user to select items that begin with a number. If you have a default option that you want them to be able to select (something like "Select") then we'll need to adjust the script to allow for that, too (assuming it doesn't start with a number, either).

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 20, 2021 Mar 20, 2021

Thank you so much for your suggestion. That is turly amazing - it works, but I am UNABLE to select the " " option that I have as the very option inthe dropdown list. The first option signifies no user seleciton.

 

The consequence of this is that if I select a value with a number and then change my mind and want to go back to the very first option (" "), I am unable to select that. The selection reverts back to the selection with the number.

 

Could you please suggest a tweek to the code that will allow me to either select " " or a number and nothing else.

 

I really appreciate your quick help - it is amazing to see it work. Almost there. Thanks again.

GC

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 20, 2021 Mar 20, 2021

Try this version of the code:

 

if (event.value) event.rc = /^\d/.test(event.value) || event.value==event.target.defaultValue;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 20, 2021 Mar 20, 2021
LATEST

That worked perfectly. Thanks so much for your assistance. That was most kind. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines