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

User-changeable colours

Hi,

I have a simple table with two cells.

I'd like to present another two tables with 4 coloured cells (say, red,
blue, green and yellow), and invite the user to click on a colour in one
table to change the backround of the first cell, and on a colour in the
second table to change the background of the second cell.

Does anyone know if there's a reasonably simple way to do this? Or can
someone show me a sample?

Thanks for any hellp.
Jul 23 '05 #1
5 1227
Jc
Tim Green wrote:
I have a simple table with two cells.

I'd like to present another two tables with 4 coloured cells (say, red,
blue, green and yellow), and invite the user to click on a colour in one
table to change the backround of the first cell, and on a colour in the
second table to change the background of the second cell.

Does anyone know if there's a reasonably simple way to do this? Or can
someone show me a sample?


This can be done using javascript. You may want to read a tutorial on
javascript and the Document Object Model (DOM) that javascript can
access in a browser environment. Here's a link to a tutorial:
http://www.w3schools.com/dhtml/default.asp

You will eventually need to use the onclick event, and a way to access
the target table, one of which is the document.getElementById method.
You could then navigate the DOM to the desired cell and set the color
using the style object (CSS).

The FAQ for this group has links to other references which may also be
of use: http://www.jibbering.com/faq/.

Jul 23 '05 #2
Tim Green wrote:
I have a simple table with two cells.

I'd like to present another two tables with 4 coloured cells (say,
red, blue, green and yellow), and invite the user to click on a
colour in one table to change the backround of the first cell, and on
a colour in the second table to change the background of the second
cell.


That is such an utterly pointless thing to do that it sounds like a
school/college assignment. Is it?

Richard.

Jul 23 '05 #3
For JC: Thank you.

For Richard: No, it's not a school assignment. What I need to do is more
complex and is a real-world application. It seemed pointless to describe it
all, so I took the essence of one problem and created a simple,
understandable example. Solve the simple example, and I've solved my
colour-change problem.

Tim
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:d9*******************@news.demon.co.uk...
Tim Green wrote:
I have a simple table with two cells.

I'd like to present another two tables with 4 coloured cells (say,
red, blue, green and yellow), and invite the user to click on a
colour in one table to change the backround of the first cell, and on
a colour in the second table to change the background of the second
cell.


That is such an utterly pointless thing to do that it sounds like a
school/college assignment. Is it?

Richard.

Jul 23 '05 #4

Give both the targetted objects/nodes, in this case the cells, an ID, the
use on the one receiving the click
onclick="document.getElementById(YOURIDHERE).style .background='YOURCOLORHERE'";,
I use something akin to that for a color checker off a list, along the
lines of <td style="background: #789"
onclick="document.getElementById(YOURIDHERE).style .backgroundColor=this.style.backgroundColor">
so, the user can just click on the colored cell to use it on the IDed box.

Danny

On Sat, 18 Jun 2005 19:16:04 -0700, Tim Green <st********@sympatico.ca>
wrote:
Hi,

I have a simple table with two cells.

I'd like to present another two tables with 4 coloured cells (say, red,
blue, green and yellow), and invite the user to click on a colour in one
table to change the backround of the first cell, and on a colour in the
second table to change the background of the second cell.

Does anyone know if there's a reasonably simple way to do this? Or can
someone show me a sample?

Thanks for any hellp.


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Jul 23 '05 #5
Hi Danny,

I read a few of the references (before seeing your note), and experimented a
little. Took me all Sunday, but I got exactly what I was looking for. And
used the same technique you describe. I also learned I could pass arguments
to the function I created, so I didn't have to create all kinds of extra
code.

Thanks. Wish I had seen your note first... :)

- Tim
"Danny" <da*******@bluebottle.com> wrote in message
news:1119228805.d74dafb4daa0fc38e13710fee8c12466@t eranews...

Give both the targetted objects/nodes, in this case the cells, an ID, the
use on the one receiving the click
onclick="document.getElementById(YOURIDHERE).style .background='YOURCOLORHERE'";,
I use something akin to that for a color checker off a list, along the
lines of <td style="background: #789"
onclick="document.getElementById(YOURIDHERE).style .backgroundColor=this.style.backgroundColor">
so, the user can just click on the colored cell to use it on the IDed box.

Danny

On Sat, 18 Jun 2005 19:16:04 -0700, Tim Green <st********@sympatico.ca>
wrote:
Hi,

I have a simple table with two cells.

I'd like to present another two tables with 4 coloured cells (say, red,
blue, green and yellow), and invite the user to click on a colour in one
table to change the backround of the first cell, and on a colour in the
second table to change the background of the second cell.

Does anyone know if there's a reasonably simple way to do this? Or can
someone show me a sample?

Thanks for any hellp.


--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/

Jul 23 '05 #6

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

Similar topics

60
by: Fotios | last post by:
Hi guys, I have put together a flexible client-side user agent detector (written in js). I thought that some of you may find it useful. Code is here: http://fotios.cc/software/ua_detect.htm ...
3
by: zlst | last post by:
Many technological innovations rely upon User Interface Design to elevate their technical complexity to a usable product. Technology alone may not win user acceptance and subsequent marketability....
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
7
by: jsale | last post by:
I'm currently using ASP.NET with VS2003 and SQL Server 2003. The ASP.NET app i have made is running on IIS v6 and consists of a number of pages that allow the user to read information from the...
0
by: tony | last post by:
Hello! This is a rather long mail but it's a very interesting one. I hope you read it. I have tried several times to get an answer to this mail but I have not get any answer saying something...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
1
by: Carlettus | last post by:
Dear All, sorry but I'm not sure if this is the right place to post my problem. I was using the following asp code to create users in Active Directory. Suddenly, and I don't know the reason, users...
0
by: rbukkara | last post by:
Hi, I have got the following error while trying to add a user in the LDAP Directory. javax.naming.NameNotFoundException: ; remaining name 'uid=vassila,ou=People,dc=cs,dc=uno,dc=edu' I have...
9
by: Gordon | last post by:
I want to add a feature to a project I'm working on where i have multiple users set up on my Postgres database with varying levels of access. At the bare minimum there will be a login user who...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.