I have written a function that creates a new object, the problem I am having is trying to refer to these objects in another function. When using getElemenntById I get a value "undefined". Does anyone know where im going wrong?
Expand|Select|Wrap|Line Numbers
- function showObject (){
- if (request.readyState == 4) {
- var returned = request.responseText;
- var splitResult = returned.split(" ");
- var h = splitResult[0];
- var w = splitResult[1]; // the dimensions must be set to a scale as they are to big for the screen. 25px represents 100mm
- h = h/5;
- w = w/5;
- cv = document.getElementById("canvas");
- var newObject = document.createElement('div');
- newObject.Class = g_objName;
- newObject.id = "newObject";
- newObject.innerHTML = g_objName;
- newObject.alt = g_objName;
- newObject.style.height = h;
- newObject.style.width = w;
- newObject.onmousedown=function(){grab(this);}
- cv.appendChild(newObject);
- }
- }
- function render () {
- var ww = document.getElementById("newObject").value;
- alert(ww);
- }