Skip to main content
Participant
July 17, 2025
Answered

Select numeric field value when mousing into the field

I have a nuberic field on my pdf and what I would like to know if there is anything in JavaScript that will select (highlight) the field value when you select the field with your mouse. The number gets selected when you Tab in but not when you click in with the mouse.

 

I tried some code on a mouse down event but did not work.

PDF Automation Station
Community Expert
July 17, 2025

The user can simply double click the entry in the field.  If you still want a single-click solution, assume the name of your numeric field is Number.  Create another field called Decoy and enter the following On Focus script:

this.getField("Number").setFocus();

Next, enter the following Mouse Up script in the number field:

this.getField("Decoy").setFocus();

You can't hide Decoy or make it read only or this will not work.  Instead you can make it invisible (not "hidden") by running the following script in the console:

this.getField("Decoy").rect=[0,0,0,0];

5 replies

PDF Automation Station
Community Expert
Community Expert
July 17, 2025

The user can simply double click the entry in the field.  If you still want a single-click solution, assume the name of your numeric field is Number.  Create another field called Decoy and enter the following On Focus script:

this.getField("Number").setFocus();

Next, enter the following Mouse Up script in the number field:

this.getField("Decoy").setFocus();

You can't hide Decoy or make it read only or this will not work.  Instead you can make it invisible (not "hidden") by running the following script in the console:

this.getField("Decoy").rect=[0,0,0,0];

Translate
Participant
July 18, 2025

That was awesome

Translate
PDF Automation Station
Community Expert
Community Expert
July 18, 2025

Can you please mark my answer as correct?

Translate