How to add a dynamically generated DV into a TextArea

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
womentake
Posts: 1
Last visit: Tue Apr 24, 2018 1:50 pm

How to add a dynamically generated DV into a TextArea

Post by womentake »

Hello,

We are trying to add a dynamically generated DV into a TextArea but it is not working.
We have this code:
  1. var id_emo = 0;
  2.  
  3. function add_emo (box_id, emo_id, emo_box) {
  4.  
  5.      alert('box_id: ' + box_id);
  6.  
  7.      var emoji_g = document.getElementById(emo_id).innerHTML.trim();
  8.    
  9.      alert('emoji_g: ' + emoji_g);
  10.  
  11.      var emo_elem = document.createElement('div');   
  12.      emo_elem.className = 'bigger_emoji';
  13.      ++id_emo;
  14.      var emo_div = 'emozi_' + id_emo;
  15.      emo_elem.id = emo_div;
  16.    
  17.      alert('emo_elem.id: ' + emo_elem.id);
  18.  
  19.      emo_elem.innerHTML = emoji_g;
  20.  
  21.      alert('final:' + emo_elem.innerHTML);
  22.  
  23.      alert('last:' + document.getElementById(box_id));
  24.  
  25.      document.getElementById(box_id).appendChild(emo_elem);
  26.  
  27. }
So if we use the above code, all is working OK, as per alerts you see, but when we get to last line:
document.getElementById(box_id).appendChild(emo_elem);

then the Append does not happen. And there are NO JS errors in browser.

And if we replace document.getElementById(box_id).value
then we get JS Error form browser of:
document.getElementById(...).value.appendChild is not a function

so how is this done?

Thank you in advance.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: How to add a dynamically generated DV into a TextArea

Post by jvierra »

Sorry but this is a PowerShell GUI forum. Your code looks like JavaScript. The question is also very vague.
This topic is 5 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked