I have a function that creates and returns an array of <div> each containong an <input> object:
<style type="text/css">
#divContainer { position=absolute; top: 0px; left: 0px; display: block; }
.TimeEditDiv { position:absolute; top: 0px; left: 0px; display: block; }
.TimeEditInput { border: solid; border-width: 0; margin: 0; padding: 0px;
color: white; background-color: green;
font-family: "Courier New"; font-size: 10pt; font-weight: bold;
width: 2.5em; height: 1.1em; }
</style>
<div id="divContainer">
</div>
<script language="JavaScript" type="text/javascript">
function createArray {
var divArray = [];
var container = document.getElementById("divContainer");
...
for (var x = 0; x < totalx; x++) {
divArray[x] = [];
for (var y = 0; y < totaly; y++) {
divArray[x][y] = [];
var newDiv = document.createElement('div');
newDiv.className = 'TimeEditDiv';
newDiv.id = 'TimeEditDiv_' + x + '_' + y;
var newInput = document.createElement('input');
newInput.type = 'text';
newInput.id = 'TimeEditInput_' + x + '_' + y;
newInput.className = 'TimeEditInput';
newDiv.appendChild(newInput);
container.appendChild(newDiv);
divArray[x][y] = newDiv;
}
}
return(divArray);
}
</script>
What is the best place to add an event handler (say onMouseOver) to each <input> in the array?
I've tried doing through the embedded <style> sheet:
...
.TimeEditInput { border: solid; border-width: 0; margin: 0;
onMouseOver:"this.style.color='red'";
}
...
or variations therof, but no luck!
I also tried to do it inside the function that creates the array of <input>, something like:
...
var newInput = document.createElement('input');
newInput.type = 'text';
newInput.id = 'TimeEditInput_' + loopX + '_' + loopY;
newInput.className = 'TimeEditInput';
onMouseOver = "color='red'";
...
No joy.
Can I do it outside the function, after the array has been created, using something like
...
var temp = myArray[0][0].????????????????? // add event here
...
Thanks
<style type="text/css">
#divContainer { position=absolute; top: 0px; left: 0px; display: block; }
.TimeEditDiv { position:absolute; top: 0px; left: 0px; display: block; }
.TimeEditInput { border: solid; border-width: 0; margin: 0; padding: 0px;
color: white; background-color: green;
font-family: "Courier New"; font-size: 10pt; font-weight: bold;
width: 2.5em; height: 1.1em; }
</style>
<div id="divContainer">
</div>
<script language="JavaScript" type="text/javascript">
function createArray {
var divArray = [];
var container = document.getElementById("divContainer");
...
for (var x = 0; x < totalx; x++) {
divArray[x] = [];
for (var y = 0; y < totaly; y++) {
divArray[x][y] = [];
var newDiv = document.createElement('div');
newDiv.className = 'TimeEditDiv';
newDiv.id = 'TimeEditDiv_' + x + '_' + y;
var newInput = document.createElement('input');
newInput.type = 'text';
newInput.id = 'TimeEditInput_' + x + '_' + y;
newInput.className = 'TimeEditInput';
newDiv.appendChild(newInput);
container.appendChild(newDiv);
divArray[x][y] = newDiv;
}
}
return(divArray);
}
</script>
What is the best place to add an event handler (say onMouseOver) to each <input> in the array?
I've tried doing through the embedded <style> sheet:
...
.TimeEditInput { border: solid; border-width: 0; margin: 0;
onMouseOver:"this.style.color='red'";
}
...
or variations therof, but no luck!
I also tried to do it inside the function that creates the array of <input>, something like:
...
var newInput = document.createElement('input');
newInput.type = 'text';
newInput.id = 'TimeEditInput_' + loopX + '_' + loopY;
newInput.className = 'TimeEditInput';
onMouseOver = "color='red'";
...
No joy.
Can I do it outside the function, after the array has been created, using something like
...
var temp = myArray[0][0].????????????????? // add event here
...
Thanks