HighDots Forums  

How do you change button image?

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss How do you change button image? in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
RC
 
Posts: n/a

Default How do you change button image? - 05-17-2006 , 01:49 PM






I have CSS for button like

input[type="button"] {
background-image: url(imageFile.gif);
background-repeat: no-repeat;
background-position: right center;
border-width: 0;
border-spacing: 0; padding: 0;
border-collapse: separate;
width: 15;
background-color: cyan;
}

and HTML

<form>
<input type="button" onClick="changeImage(this)">
</form>

and JavaScript

var newImage = new Image();
newImage.src = "newimageFile.gif";

function changeImage(thisbutton) {
thisbutton.style.xxxx = arrow_down.src;
}


My question is what will be for xxxx?

I try
..style.background-image for xxxx, but Netscape/Firefox and IE dosen't
like that.

..style.background is for the background-color, not for background-image.

Reply With Quote
  #2  
Old   
matt.macchia@gmail.com
 
Posts: n/a

Default Re: How do you change button image? - 05-17-2006 , 05:13 PM






Try:
thisbutton.style.backgroundImage = arrow_down.src;


Reply With Quote
  #3  
Old   
Lasse Reichstein Nielsen
 
Posts: n/a

Default Re: How do you change button image? - 05-18-2006 , 12:58 AM



matt.macchia (AT) gmail (DOT) com writes:

Quote:
Try:
thisbutton.style.backgroundImage = arrow_down.src;
I'm not sure what you are replying to (please quote enough of the
previous message to give your answer a context), but I'm guessing
that the arrow_down variable points to an Image element, and then
the answer is slightly incorrect.

A pure URL is not a valid value for the CSS background-image property.
Instead, it should be wrapped in "url(...)" and probably quoted too.
So, at least:
thisbutton.style.backgroundImage = 'url("' + arrow_down.src + '")';

Good luck
/L
--
Lasse Reichstein Nielsen - lrn (AT) hotpop (DOT) com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'


Reply With Quote
Reply




Thread Tools
Display Modes

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

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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.