473,327 Members | 1,979 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

How do you change button image?

RC
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.
May 17 '06 #1
2 5093
Try:
thisbutton.style.backgroundImage = arrow_down.src;

May 17 '06 #2
ma**********@gmail.com writes:
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 - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
May 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ben | last post by:
Hi. I have a button that change a number of images src's when I click a button. The src's are stored in an array and I just use document.src=pics to change the src of the image. However I want...
2
by: Mark Kamoski | last post by:
How can one change an image url at runtime? (Note, the image exists in a user control.) This is the image tag on the ascx... <asp:image id="TopBanner" runat="server"></asp:image> ....but...
6
by: ruca | last post by:
Hi gurus, I have a imagebutton in my WebForm, and I want that when I click (mouse down) on her the imagebutton change image and when I "unclick" (mouse up) change to the original image. Basically...
4
by: Shapper | last post by:
Hello, I have this image in my HTML code: <img src="images/en-US/myImage.jpg" /> I want to change the URL using the value of a Session variable. <img src="images/ Session("culture") Value...
3
by: NeverwaY | last post by:
How can i make a button click change an image in a picture box? I basically have an image in my main Form, i want it to change when a button is clicked. -- <XML> <BEGIN:: DCSE-TRAINING> <END::...
2
by: Tommy | last post by:
Hi all, I use DataGridView in my form and add image column and 2 textbox column, and I want to change image column's image on runtime. But there is no any example on this function. What can I do ?...
1
by: Phil_Cam | last post by:
Hello All On a webpage I have a standard paypal image button for purchases. I am trying to set it up so that it only shows up or is endabled when text is entered into a textbox and a button is...
5
by: cssExp | last post by:
Let's see i have two images. $image1 = mysql_query('SELECT `image` FROM `images` WHERE `image`=`image1.jpg`"); $image2 = mysql_query('SELECT `image` FROM `images` WHERE `image`=`image2.jpg`"); ...
2
by: Jim | last post by:
How can I use JavaScript to change a background image in a table cell? Here's the code for the cell <td width="338" valign="top" background="../images/ LEC_Q1.jpg"><div...
4
by: Peter | last post by:
I have a DataList and each item in the datalist has an imge, I want to change the datalist item image on the client side when user clicks a button. How would I do that with JavaScript, does anyone...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.