[thelist] getting position of non-positioned elements
Karen Bowen
KarenB at frontiersoftware.com.au
Fri Dec 15 00:28:27 CST 2000
Thanks Jeff. The extra lines for object detection is what I was hoping to
avoid, as there are 200 or so pages with up to 6 select boxes each,
referenced many times in 2 different page-specific functions for dynamic
population... To add the if/else case for each... ick!
However the new code works really well, except that we've now discovered a
couple of pages that create a new input box for each select option as it's
returned... ending up with 4 or 5 input boxes replacing each select box!
I'm going to try using a counter or something similar to ensure only one is
created, which I'm pretty sure should work. (hope!)
If anyone wants to see, this is the code for the 2 dropDown functions now:
// *********************************************************************
function dropDownsOff() {
var w = glob.dataFrame;
var d = w.document;
var f = d.forms[0];
var num = 0;
for (var i=0; i< f.length; i++) {
var el = f[i];
if (el.tagName == "SELECT") {
var holder = d.createElement("INPUT"); // new input box
var sel = el.selectedIndex; // get selection
var par = el.parentNode; // get parent node
oTemp = par.appendChild(holder);
parForm = par; // store globally
if (sel != -1) {
// something selected
var val = el[sel].value;
var txt = el[sel].text;
} else {
// nothing has been selected, so do an empty input box
var val = "";
var txt = "Nothing selected.";
}
holder.value = txt;
holder.text = txt;
holder.className = el.className;
// Store objects for toggling
glob.aSelBoxes[num] = el; // store orig. select box
glob.aReplBoxes[num] = holder; // store temp replcmt box
// toggle display of input & select boxes
el.style.display = "none";
holder.style.display = "inline";
num++;
}
}
return;
}
// *********************************************************************
// Return page to normal state (Show select boxes)
function dropDownsOn() {
for (var i=0; i<numSels; i++) {
glob.aReplBoxes[i].style.display = "none";
glob.aSelBoxes[i].style.display = "inline";
}
// Re-initialise arrays
glob.aSelBoxes = new Array();
glob.aReplBoxes = new Array();
return;
}
// *********************************************************************
Thanks so much to everyone for all the help!
Karen
> -----Original Message-----
> From: jeff [SMTP:jeff at lists.evolt.org]
>
> this is correct. as soon as you alter the innerHTML of the tag containing
> the element, that element is removed from the page. so, to make sure you
> can still access just do some object detection.
>
More information about the thelist
mailing list