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

Inject Javascript during run-time in HTML5 forms

Avatar

Avatar
Validate 10
Level 5
tarekahf
Level 5

Likes

32 likes

Total Posts

409 posts

Correct Reply

10 solutions
Top badges earned
Validate 10
Validate 1
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Validate 10
Level 5
tarekahf
Level 5

Likes

32 likes

Total Posts

409 posts

Correct Reply

10 solutions
Top badges earned
Validate 10
Validate 1
Give Back 50
Give Back 5
Give Back 3
View profile
tarekahf
Level 5

12-05-2016

I found out that under HTML5 forms I can write Javascript code that can access the entire document model and any code that would normally run in a browser, it would run under HTML5 element events.

For example see snapshots below below. I add this code to the click event:

debugger; txtImageStr.rawValue = imgFld.rawValue; imgFld.rawValue = null; app.alert("button id _5 = " + document.getElementById("_5").id); document.getElementsByName("_5")[0].addEventListener("click", myFunc)

And it worked properly when used the LC Forms Manager to preview the form

Question: Does this mean I can use Javascript Code Injection method to enrich the client side functionality for example, to add image controls and similar stuff?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 5
Level 2
sudhanshu_singh
Level 2

Likes

8 likes

Total Posts

15 posts

Correct Reply

4 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile

Avatar
Boost 5
Level 2
sudhanshu_singh
Level 2

Likes

8 likes

Total Posts

15 posts

Correct Reply

4 solutions
Top badges earned
Boost 5
Boost 3
Boost 1
Affirm 3
Affirm 1
View profile
sudhanshu_singh
Level 2

12-05-2016

The HTML DOM structure is internal and can change with updates, so one should never work with the HTML DOM elements directly from HTML5 form. Also the changes made to the DOM would not be reflected to the model automatically. For the use case you mentioned (add image controls) you should follow the customization guide: https://helpx.adobe.com/aem-forms/6-2/custom-widgets.html

Answers (0)