Readdy Write  
0,00 €
Your View Money
Views: Count
Self 20% 0
Your Content 60% 0

Users by Links 0
u1*(Content+Views) 10% 0
Follow-Follower 0
s2*(Income) 5% 0

Count
Followers 0
Login Register as User

Javascript: insert text into a form field

20.05.2018 (👁2406)


 

In an HTML form field, when using javascript, you must work with the property: Value.

 

Beispeil:

var ctlTitle = document.getElementById("ctlTitle");

ctlTitle.value = "🎬 " + ctlTitle.value;

 

Here, the character

🎬 is inserted in a form field at position 0

 

Note:

For form fields, unfortunately, it is not possible to insert a text as HTML element or child

//var txtVideo = document.createTextNode("🎞");

//if (ctlTitle.childNodes.length > 0)

//{ ctlTitle.insertBefore(txtVideo, ctlTitle.childNodes[0]); }

//else

//{ ctlTitle.appendChild(txtVideo); }