How to change h: outputText value to JavaScript?

I already tested with 2 inputText, it works well for example

var tdate = document.getElementById('txtDate'); //h:inputText var tdt = document.getElementById('txtDateTime'); //h:inputText tdate.onchange = function(){ tdt.value = tdate.value; }; 

How can I change the value of "tdt" to h: outputText?

 var tdate = document.getElementById('txtDate'); //h:inputText var tdt = document.getElementById('txtDateTime'); //h:outputText 
+6
source share
1 answer

Look into the generated HTML source. Rightclick in the browser and view the source. You will see that <h:outputText> displays an HTML <span> element with a value in its body. To change the <span> body in JavaScript, you need to manipulate innerHTML .

 tdt.innerHTML = "new value"; 
+3
source

Source: https://habr.com/ru/post/917148/


All Articles