Copy link to clipboard
Copied
Hello all,
Im using Adobe Acrobat Standard DC
I have been trying to figure this out all day and have a deadline approaching.
I have very little knowledge in writing javascript so I am rather clueless.
I am trying to figure out a script to run that allows my form boxes to highlight all the text in it upon clicking the box. Currectly where ever I click it drops my cursor, usually in the middle of a text string.
I also need this to happen for all my text fields so I'm looking for something that I do not have to input the name of the field for every single box.
After digging online I found this, but im not sure it will work for me.
<script type="text/javascript"> function SelectAll(id)
{
document.getElementById(id).focus(); document.getElementById(id).select();
}
Any help would be very much appreciated.
Copy link to clipboard
Copied
That code is designed to work with an HTML form and won't work with a PDF form.
I think the best you can do for a field in a PDF is the following in the Mouse Enter event:
// Mouse Enter script for text field
event.target.setFocus();
Selecting all of the text is a side-effect of using the setFocus method. What I suggested results in non-standard behavior, but it might be OK for your needs.
Copy link to clipboard
Copied
Hey George,
Thanks so much for the response!
I tried it out and it would work well, however this will mostly be used on mobile devices. I am unable to hover on my mobile so this doesn't work for me. Any other ideas??
Thanks
Copy link to clipboard
Copied
There's not anything that will work with the mobile versions of Acrobat/Reader.
Copy link to clipboard
Copied
Thanks george. Yes it seems there is no way to do this. I was able to add buttons to highlight the field but now ill need 50 buttons next to every box...seems like such a common thing to not have a solution to.
Copy link to clipboard
Copied
I was able to find this code upon searching. I dont know enough about javascript to know if it will do what I need. Anyone able to take a look?
Here is original thread
javascript - Select text with just one click - Code Review Stack Exchange
function SelectText(element) {
var doc = document,
text = doc.getElementById(element),
range,
selection;
if (doc.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(text);
range.select();
} else if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(text);
selection.removeAllRanges();
selection.addRange(range);
}
}
$(function() {
$('p').click(function () {
SelectText('autoselect');
});
});
Copy link to clipboard
Copied
That code is for an HTML form as well and won't work with a PDF form.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now