hi,
i've got some trouble with setting IFRAME src dynamically. The src is set to the page i need only if it is followed by an ALERT msg
The code i'm working on in ASP is derived from the Tree View at
www.planet-source-code.com/vb/scripts/ ShowCode.asp?txtCodeId=6411&lngWId=4
I've got 4 levels in the tree. i want to retrieve the 4th level from the server....so i'm using IFRAMEs . i've saved the pg generated by ASP & modified it to make it brief but workable.you may copy paste it to try it out. yes its ugly but pls adjust & help me out.
the iframe src is not set unless the alert message follows it.Now i do NOT need the alert message. how do make the IFRAME work without having to follow it with the ALERT window ? i don't know what i'm missing out but i find this really weird right now.
i have commented the 2 offending lines in the code that follows
document.getElementById("f"+icnt).src="item.asp?brand="+brand;
//in place of item.asp...u may set it to any html page
alert("brand is " + brand);
//if this is commented a blank page appears....can be checked by right-clicking & viewing Properties
thanks for your time & patience.......
<script language='javascript' type="text/javascript" >
var tc = 0;
//td works for level 1,2,3
function td(oButton, oItems)
{
if ((oItems.style.display == "") || (oItems.style.display == "none"))
{
oItems.style.display = "block";
oButton.src = "minus.gif";
}
else
{
oItems.style.display = "none";oButton.src = "plus.gif";
}
return false;
}
//tdo works for the 4th level
function tdo(oButton, oItems,brand,icnt)
{
if ((oItems.style.display == "") || (oItems.style.display == "none"))
{
oItems.style.display = "block";
oButton.src = "minus.gif";
///////////////////////////mind bender//////////////////////////////////
document.getElementById("f"+icnt).src="item.asp?brand="+brand;
//in place of item.asp...u may set it to any html page
alert("brand is " + brand);
//comment the alert line to notice difference
//////////////////////////mind bender///////////////////////////////
}
else
{
oItems.style.display = "none";
oButton.src = "plus.gif";document.getElementById("f"+icnt).src="item.asp?brand="+brand;
}
return false;
}
function hd(oItems) {oItems.style.display = "none";}
function sd(oItems) {oItems.style.display = "block";}
</script>
<body bgcolor='#FFFFFF' onLoad="hide()" ><form method='post' name="myform">
<a href='javascript:d()' ONCLICK='javascript:td(b1Btn, b1chlds)' class='nav'><IMG SRC='plus.gif' ID='b1Btn' border='0'>
<i class='cat'>Alc</i></a><br>
<div ID='b1chlds'><script>hd(b1chlds);</script>
<a href='javascript:d()' ONCLICK='javascript:td(b2Btn, b2chlds)' class='nav'>
<IMG SRC='plus.gif' ID='b2Btn' border='0'><i class='subcat'>Beer</i></a>
<br>
<div ID='b2chlds'><script>hd(b2chlds);</script>
<a href='javascript:d()' ONCLICK='javascript:tdo(b3Btn, b3chlds,"C",3)' class='nav'>
<IMG SRC='plus.gif' ID='b3Btn' border='0'><i class='brand'>Budweiser</i></a><br>
<div ID='b3chlds'><script>hd(b3chlds);</script>
<iframe id='f3' name='a3' scrolling='no' frameborder='1' WIDTH=800 HEIGHT=200></iframe>
</div>
</div>
</div>
<a href='javascript:d()' ONCLICK='javascript:td(b8Btn, b8chlds)' class='nav'>
<IMG SRC='plus.gif' ID='b8Btn' border='0'><i class='cat'>Soft Drinks</i></a><br>
<div ID='b8chlds'><script>hd(b8chlds);</script> <a href='javascript:d()' ONCLICK='javascript:td(b9Btn, b9chlds)' class='nav'><IMG SRC='plus.gif' ID='b9Btn' border='0'><i class='subcat'>Colas</i></a>
<br>
<div ID='b9chlds'>
<script>hd(b9chlds);</script>
<a href='javascript:d()' ONCLICK='javascript:tdo(b10Btn, b10chlds,"A",10)' class='nav'>
<IMG SRC='plus.gif' ID='b10Btn' border='0'>
<i class='brand'>Croak</i>
</a><br>
<div ID='b10chlds'><script>hd(b10chlds);</script>
<iframe id='f10' name='a10' scrolling='no' frameborder='1' WIDTH=800 HEIGHT=200></iframe>
</div>
<a href='javascript:d()' ONCLICK='javascript:tdo(b12Btn, b12chlds,"Q",12)' class='nav'>
<IMG SRC='plus.gif' ID='b12Btn' border='0'><i class='brand'>Popsy</i></a>
<br>
<div ID='b12chlds'><script>hd(b12chlds);</script>
<iframe id='f12' scrolling='no' frameborder='1' WIDTH=800 HEIGHT=200></iframe>
</div>
</div>
</div>
</form></body></html>