6

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
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Peter
  • 155
  • 2
  • 2
  • 8

1 Answers1

3

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";
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555