...

View Full Version : One pass it's there, the next it's gone?!?



ggallen
08-09-2004, 08:07 PM
I have the following subroutines:

function selphone(aoffset) {
var offid=document.getElementById("DROP"+aoffset);
alert(offid.style.display);
offid.style.display="";
var selid=document.getElementById("SELFONE"+aoffset);
selid.options.length=19;
for (var i=0 ; i<19 ; i=i+1) {
selid.options[i].text = phonenames[i];
selid.options[i].value = i+1;
}
selid.focus();
return;
}
function hidephone(aoffset) {
var offid=document.getElementById("DROP"+aoffset);
var selid=document.getElementById("SELFONE"+aoffset);
var textid=document.getElementById("PHONED"+aoffset);
var labid=document.getElementById("LABEL"+aoffset);
var labelnm=selid.options[selid.options.selectedIndex].text;
if (labelnm != "Click for options") {
labid.innerText=labelnm;
}
offid.style.visibility="hidden";
offid.style.display="none";
textid.focus();
return;
}
function updatephone(aoffset) {
var textid=document.getElementById("PHONED"+aoffset);
return;
}


and the following HTML
<TD WIDTH=10% ALIGN="LEFT" ID="LABEL2">Home
<DIV ID='DROP2' STYLE='display:none' ALIGN='CENTER'>
<SELECT NAME='SELFONE2' SIZE='1' OnChange="hidephone('2');" OnBlur="hidephone('2');">
</SELECT>
</DIV></TD>
<TD WIDTH=5% ALIGN="CENTER"><BUTTON OnClick="selphone('2');"><IMG SRC="/arrow.gif"></BUTTON></TD>
<TD WIDTH=20% ALIGN="LEFT"><INPUT TYPE="TEXT" NAME="PHONED2" VALUE="" SIZE=25 OnChange="updatephone('2');"></TD>
<TD WIDTH=20%></TD>

If you click on the arrow image, a select array should first be set to 19,
then filled with 19 items from another array (created in javascript). once a selection is made, it should copy "text" selected to the innerText where "Home" was, then hide the selection box, then focus() to the Phone box.

OK. all works great. Until you try to click it again, then it gives you an Obect required error (IE). If I remove the line: labid.innerText=labelnm;
from the one hidephone() subroutine, it works fine.

Why does changing the innerText destroy an object that isn't part of that text parent? Or do I not have the innerText setup properly??

George

ggallen
08-09-2004, 08:09 PM
duhhh..

Nevermind...I see it now.

I have my <DIV></DIV> included in the <TD></TD> so when
I write out the new innerText it overwrites the (or deletes)
the <DIV section>.

Now is there anyway to just write to the area between the
<TD> and the <DIV> ?? without a complicated string parsing
routine to only change that part?

George

ggallen
08-09-2004, 08:34 PM
my solution:

change:
<TD WIDTH=10% ALIGN="LEFT" ID="LABEL2">Home
<DIV ID='DROP2' STYLE='display:none' ALIGN='CENTER'>

to
<TD WIDTH=10% ALIGN="LEFT"><DIV ID="LABEL2">Home</DIV>
<DIV ID='DROP2' STYLE='display:none' ALIGN='CENTER'>

The only reason I ID'd the <TD..> was to get to the label.
So instead I just put the label in a <DIV></DIV> of it's own.

Works now.

George



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum