473,405 Members | 2,187 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,405 software developers and data experts.

Table-tag

Hello,

I have a little question which should be easy, nevertheless i can't
solve the problem.

I want to change the background of a <td>-tag when you click on a link
in the html-page.

This is what I've got but it doesn't work:

<script type="text/javascript">
function change()
{
var x=document.getElementById('table').rows
var y=x[0].cells
y[0].background="../images/knoplinks.gif"
}

<script>

<table id="tabel">
<tr>
<td background="../images/knop2.gif">
<a href="#" onclick="change()">Gegevens</a>
</td>
</tr>
</table>

Jul 23 '05 #1
4 1243
"Nattydreadlock" <Be********@hotmail.com> skrev i meddelandet
news:11**********************@z14g2000cwz.googlegr oups.com...
Hello,

I have a little question which should be easy, nevertheless i can't
solve the problem.

I want to change the background of a <td>-tag when you click on a link
in the html-page.

This is what I've got but it doesn't work:

<script type="text/javascript">
function change()
{
var x=document.getElementById('table').rows
Add ";"
var y=x[0].cells
Add ";"
y[0].background="../images/knoplinks.gif"
Add ";"
And you probably want "y[0].style.background =
url(../images/knoplinks.gif)".
(or "y[0].style.backgroundImage....".)
}

<script>
Should be: "</script>".
<table id="tabel">
But you wrote "getElementById('table')".
<tr>
<td background="../images/knop2.gif">
<td> doesn't have a background attribute (at least not in HTML 4.0).
Perhaps you want "<td style="background-image:url(../images/knop2.gif)">".
<a href="#" onclick="change()">Gegevens</a>
</td>
</tr>
</table>


--
Joakim Braun
Jul 23 '05 #2
Hello,

I checked the syntax problems but still it doesn't work. I tried
different things but I couldn't find the solution yet.
Here is what I think is closest to the solution

<script type="text/javascript">
function change()
{
var x=document.getElementById('tabel').rows;
var y=x[0].cells;
y[0].style = "background-image:url(../images/knop2klik.gif)";
}
</script>
<table id="tabel">
<tr>
<td style="background-image:url(../images/knop2.gif)">
<a href="#" class="navlinks"
onclick="change()">Gegevens</a>
</td>
</tr>
</table>

Jul 23 '05 #3
Ivo
"Nattydreadlock" wrote

y[0].style = "background-image:url(../images/knop2klik.gif)";


Make that:
y[0].style.backgroundImage = "url(../images/knop2klik.gif)";

with an uppercase i.

hth
--
Ivo
Jul 23 '05 #4
On 25/03/2005 12:27, Nattydreadlock wrote:

[snip]
I want to change the background of a <td>-tag when you click on a link
in the html-page.
Make sure that if you set a background image, you also set both a
background and foreground colour. You shouldn't rely on defaults in
case a user doesn't have those same defaults.

[snip]
y[0].background="../images/knoplinks.gif"
Use the backgroundImage property of the style object, and the url(...)
functional notation, as shown in Ivo's post.

[snip]
<a href="#" onclick="change()">Gegevens</a>


You'll probably want to cancel the click event. Return false from the
listener:

onclick="change(); return false;"

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #5

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

Similar topics

4
by: Gaz | last post by:
Hi, I need to have a table nested within another table. The tables are alongside each other visually speaking, and the nested table (on the right) can vary in size. My problem is that when the...
3
by: Terrence Brannon | last post by:
I don't know what Postgres considers a relation and had no intention of creating one when piping my schema to it... I always DROP TABLE before CREATE TABLE, so here are the ERRORS emitted when...
4
by: maricel | last post by:
I have the following base table structure - DDL: CREATE TABLE "ADMINISTRATOR"."T1" ( "C1" INTEGER NOT NULL ) IN "TEST_TS" ; ALTER TABLE "ADMINISTRATOR"."T1" ADD PRIMARY KEY
4
by: Simone Battagliero | last post by:
I wrote a program which inserts and finds elements in an hash table. Each element of the table is a dinamic list, which holds all elements having the same hash value (calculated by an int...
117
by: phil-news-nospam | last post by:
Is there really any advantage to using DIV elements with float style properies, vs. the old method of TABLE and TR and TD? I'm finding that by using DIV, it still involves the same number of...
76
MMcCarthy
by: MMcCarthy | last post by:
Normalisation is the term used to describe how you break a file down into tables to create a database. There are 3 or 4 major steps involved known as 1NF (First Normal Form), 2NF (Second Normal...
7
by: Kamal | last post by:
Hello all, I have a very simple html table with collapsible rows and sorting capabilities. The collapsible row is hidden with css rule (display:none). When one clicks in the left of the...
5
by: wugon.net | last post by:
question: db2 LUW V8 UNION ALL with table function month() have bad query performance Env: db2 LUW V8 + FP14 Problem : We have history data from 2005/01/01 ~ 2007/05/xx in single big...
12
by: Michael.Z | last post by:
Anyone who can help: Given a Table.h file I am writing a Table.c file. I keep getting the compile error: previous declaration of Table was here / conflicting types for I think the...
5
by: jrod11 | last post by:
hi, I found a jquery html table sorting code i have implemented. I am trying to figure out how to edit how many colums there are, but every time i remove code that I think controls how many colums...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.