...

View Full Version : "object required" error



kreskin
07-12-2004, 06:14 PM
Hello. I m trying to create an expand/hide button. It would be an image that, when clicked, would either expand or hide a table and change the img src from arrow-up to arrow-down or vice versa. I'm getting an "object expected" error in the following code:

<script type="javascript">
function displ(tblID, that)
{
var showhide;
showhide='';
if (that.src=="images/blackD.gif"); //click on down, show table
{
showhide=='block';
up(that);
}
else
{
showhide=='none';
down(that);
}

showhide='block';
window.document.getElementById(tblID).style.display=showhide;
return true;
}

function up(that)
{
imgU = new Image(); imgU.src = "images/blackU.gif";
that.src=imgU.src;
}

function down(that)
{
imgD = new Image(); imgD.src = "images/blackD.gif";
that.src=imgD.src;
}

</script>

<img src="./images/blackU.gif" alt="" width="12" height="10" border="0" onclick="displ('tbl', this);">

<!--A table with id='tbl'-->

I get the error on the img line, when I'm calling the function. Anyone know why that is? Thanks in advance,

Igor.

Vincent Puglia
07-12-2004, 07:24 PM
Hi Igor,

1) <script type="text/javascript">
2) '== ' is for comparison (means 'is equal to')
'=' is for assignment (means fill left with right)
3) if (.....);
means do nothing -- get rid of the semi-colon

Vinny



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum