Unable to set dynamic text for layout cell's setText method

Hi,
I’ve been trying to set dynamic text to my layout cell by adding div element to it. But the value it displays is ‘undefined’.


function doOnLoad(){
// myReporteesCombo is defined
//layout is defined
.
.
myLayout.cells("a").setText(myLayout.cells("a").attachHTMLString('<div id = "statsForEmployee"> </div>')); // displays as undefined
.
.
scheduler.attachEvent("onViewChange",function(view,date){
		var comboNameSelected = myReporteesCombo.getSelectedText();
		if(comboNameSelected === "DIRECT REPORTS"){
	               	           alert("Yes Direct reports, depth 1"); //I see this alert too
		                   document.getElementById("statsForEmployee").innerHTML = "Statistics for" + username;  // Cannot set property //'innerHTML' of null is the error here. username is a global variable.
		}
});
} // function ends
</head>
<body onload="doOnLoad();">     
	<div id="layoutObj"></div>	
......
</body>
</html>

I need to assign dynamic value to div id in multiple events like OnChange, onViewChange etc in doOnLoad(). But I’m missing out on something. Please help me.

Resolved it myself. I tried to add the div id direct to setText.

myLayout.cells("a").setText('<div id = "statsForEmployee"> </div>'); and then it was all fine.