Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-12-2004, 05:14 PM   PM User | #1
kreskin
New to the CF scene

 
Join Date: Jul 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
kreskin is an unknown quantity at this point
Question "object required" error

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.
kreskin is offline   Reply With Quote
Old 07-12-2004, 06:24 PM   PM User | #2
Vincent Puglia
Regular Coder

 
Join Date: Jul 2003
Location: where the World once stood
Posts: 256
Thanks: 0
Thanked 2 Times in 2 Posts
Vincent Puglia is an unknown quantity at this point
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
__________________
mod at WebXperts
Vincent Puglia is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:38 PM.


Advertisement
Log in to turn off these ads.