Adding text into a PDF button with 1 click using Javascript - javascript

I'm creating a staff document which requires only 2 things to be unlocked.
1. A placeholder for an image, I've implemented that just fine by creating a button with "Icon only" and using a javascript code as follows:
// Mouse Up script to import a button icon
event.target.buttonImportIcon();
It works perfectly!
However I also need a text field which can be clicked once, and have text filled in and saved, because quite frankly the people that will be using the document, couldn't edit a PDF if the human race depended on it haha
Any help would be appreciated greatly!!! Thanks!

Create a text field (which I'm assuming you will want to start off as empty) and then add the following command to activate on Mouse Down:
(this.getField("TextFieldName")).value = "The text that you want to add...";
Where TextFieldName is the reference to the text field that you want to auto fill.
This will make the text appear when the text field is clicked. You could add a clear button using similar code so that erroneous clicks can be undone. Also, you could set the field to be read only to prevent unwanted changes to the auto filled text.

Related

Text in textarea dissapear when auto populated with add-on Autofill

A page I am testing is built with react. On the page I have checkboxes and text areas. Now I am trying to use the Chrome plugin Autofill in order to populate the fields. The check box selection remains after I click on NEXT button (to go to next page) but the numbers that are written to the text areas disappear!
Anyone that has any ideas on what this could be?
I use simple javascript code that populates the text field and that works fine, I see the text but it seems like the page does not recognize it is populated when I click on Next button:
document.getElementsByName("price")[0].value=123456
I have also tried with
document.getElementsByName("price")[0].value="2500123"
Both lines populate the text area correctly but it disappears.
It is the same behaviour even if I use that javascript in F12. Still the text will dissapear when I have click on Next button. But not the check box selection!
When I enter 123456 manually I can continue with Next button.
All input is appreciated.

How do I use javascript in Acrobat?

I am creating an Acrobat file with multiple pages. Each page has a map and a list of names down the side. Each name is a button and I have JavaScript entered for each, so that when you hover the mouse over the button, the corresponding name shows up at it's location on the map (via a text field), and then when you move your cursor away from the button, the text field disappears.
Here is the code I have for MouseEnter:
this.getField("Kyle Deal").display = display.visible;
Here is the code I have for MouseExit:
this.getField("Kyle Deal").display = display.hidden;
It works great if you stay on one page, but my problem is, is that when you hover the mouse over the button and the name appears and you move to a new page, and then come back, the text field is still there because the MouseExit never actually triggered when you were on the page the first time, no matter where your cursor is now. This happens way more often than it sounds like it might, pretty much every time someone uses this document at all.
Does anyone have an idea of how I can go about resolving this issue whether it be by a bit of JavaScript that clears all functions when you move to a new page, or maybe I can edit the MouseEnter function to go away after a certain period of time, or some other method inside Acrobat's settings?
One approach would need some field renaming (to make things easier). You would set all relevant fields to hidden when leaving the page.
Now with hierarchical field names, where the fields on page 2, for example, would have a name "p2.xxx", your command in the pageOut event would be
this.getField("p2").display = display.hidden ;
and that would do it.
Otherwise, you would have to hide field by field in the pageOut event.

Hyperlinks does not work in read-only text field in acrobat

I have a pdf fillable form where I am allowing the user to enter additional remarks/comments in a text area.
The issue is that some want to enter hyperlink in the text area, which works fine until the text-area is active. When the form is saved, all fields are made read-only and the hyper-link is not clickable. I tried flattening the page, but even then the link is not clickable.
Is there any way to achieve this?
There are two questions here.
You can add hyperlinks to text field and have them remain functional if the field is set to allow for Rich Text. If the field doesn't allow rich text, any hyperlinks entered will revert back to plain text when the field is exited.
Read-only fields are ignored by the mouse. I'd need to understand more about how the PDF is created and what the rest of your code does to recommend a work around.

Moving textarea content to input field and back removes new lines. How to overcome?

That's it.
The web app that I am working on is pretty big and I am not sure whether field can get their types changed.
Anyway,
we have a textarea in a popup that on some text entered and Save button in the popup clicked, moves all the textbox content to an input field of type text.
Later if a user clicks on the input field he gets the popup with the textbox rendered again and the textbox content is obtained from the input.
The issue occurs already at the first shift as all new lines are removed on moving the text from the textarea to the input field.
I have found that the reason for new lines missing is that html requires tags introduced in order to render those, but I have expected the text to keep formatting after getting back to the same textbox.
Why are new-line characters removed from the string?
Do you have any suggestion how to overcome that? I am not sure whether I will be able to change the field types.
Something you could do is, when you save and move the content to the input, you can store the "textarea" value on a javascript variable. Then, when opening the popup again, place the variable value to the textarea, and the formatting will be still there.

Text box with a clear button inside in asp.net

I have a lot on my site text boxes whose content is a date
So I will not have to check correctness did it read-only
Until now next to each text box was two buttons, one to add date opened popup calendar, second to delete the date (values ​​not required)
Now I wanted to go to ajax calendarextender that the buttons were just ugly
My problem is that this control is not have delete button, and I do want to allow the user to deleted but not cancel the properties read-only to text box And I do not want to leave the ugly button.
My question:
If calendarextender ajax or something similar with a delete button from the popup
Alternatively if you have the option text box with a delete button inside( as text boxes IE10)
With the help of css and java-script you can easily do it.
Here is an example How do I put a clear button inside my HTML text input box like the iPhone does?
Instead of all that work to make it read-only and avoid validation, why not combine a FilteredTextBoxExtender with the CalendarExtender. Use the filter to block all non-numeric characters. I still think it's better to do the validation. It's as simple as DateTime.TryParse(), or you could do it client-side with the built-in FieldValidators.

Categories