Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change h:outputText value by JavaScript?

Tags:

javascript

jsf

I already tested with 2 inputText, It runs 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 " - h:outputText?

var tdate = document.getElementById('txtDate');    //h:inputText
var tdt = document.getElementById('txtDateTime');  //h:outputText
like image 751
Peter Avatar asked Jun 01 '12 04:06

Peter


1 Answers

Look in the generated HTML source. Rightclick page in browser and view source. You'll see that the <h:outputText> renders a HTML <span> element with the value in its body. To alter the body of a <span> in JavaScript you need to manipulate the innerHTML.

tdt.innerHTML = "new value";
like image 87
BalusC Avatar answered Oct 21 '22 18:10

BalusC