Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Table Background change with Link
Old 11-04-2005, 07:29 PM Table Background change with Link
Monkeon's Avatar
Skilled Talker

Posts: 59
Trades: 0
Hi, I'd really appreciate any help I can get on this, coz it's driving me mad!

I'm trying to change the cell background of a table when a link is clicked.

here's my script

Code:
<script language="JavaScript">
<!--

var backImage = new Array();

backImage[0] = "";
backImage[1] = "images/backgrounds/background1.gif";
backImage[2] = "images/backgrounds/background2.gif";
backImage[3] = "images/backgrounds/background3.gif";

function changeBGImage(whichImage){
if (document.body){
document.getElementById("cellChange").style.background  = backImage[whichImage];
}
}

//-->
</script>
The Link looks like this
Code:
<a href="javascript:changeBGImage(1)">Change</a>
And the table cell is named like so

Code:
<td width="100%" id="cellChange">
Can anyone help? I am a complete noob to Java, so please be patient!
__________________

Please login or register to view this content. Registration is FREE
FREE Online Dating!
Meet your perfect match online right now!
Monkeon is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-05-2005, 04:46 AM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
for manipulating CSS styles that have a hyphen (ie: background-image, font-weight,border-width), the hyphen is removed and the first letter of the next part of the property name is capitalised.

So;
border-width becomes borderWidth,
font-weight becomes fontWeight,
background-image becomes backgroundImage (Which is the one you need to use)
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 11-06-2005, 08:57 AM
Monkeon's Avatar
Skilled Talker

Posts: 59
Trades: 0
Great! Thanks for your help!

After I tried that, it gave me an 'Invalid Argument' error. So then I found out it was because my vars were wrong

they should be

backImage[0] = "";
backImage[1] = "url(images/backgrounds/background1.gif)";
backImage[2] = "url(images/backgrounds/background2.gif)";
backImage[3] = "url(images/backgrounds/background3.gif)";

Thanks once again, this has been killing me!!!
__________________

Please login or register to view this content. Registration is FREE
FREE Online Dating!
Meet your perfect match online right now!
Monkeon is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Table Background change with Link
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.11357 seconds with 12 queries