473,606 Members | 2,885 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to highlight cell

Hi all,

I have a table with 12 cols and 10 rows. When a user clicks on a table cell;
the page is refreshed and displays some data below the table dependant on
whichever cell was selected.
I would like to make it so that whichever cell was clicked; the background
color is changed - so that when the user sees the data, (s)he can tell which
cell it relates to.

Does anyone know of a clever way to do this ?
I'm afraid my creativity is running a bit dry on this one as the only
working way i could come up with so far is to have an if statement before
each table cell is created, which is long winded.

kind regards

T
Oct 18 '06 #1
17 3370
toffee wrote:
Hi all,

I have a table with 12 cols and 10 rows. When a user clicks on a table cell;
the page is refreshed and displays some data below the table dependant on
whichever cell was selected.
I would like to make it so that whichever cell was clicked; the background
color is changed - so that when the user sees the data, (s)he can tell which
cell it relates to.

Does anyone know of a clever way to do this ?
I'm afraid my creativity is running a bit dry on this one as the only
working way i could come up with so far is to have an if statement before
each table cell is created, which is long winded.

kind regards

T
Long winded indeed.

The only other option I can think of at the moment is keeping an array
for each cell as X,Y coordinates, and the value of the array element
would be a string like 'style="backgro und-color:#CCCCCC;" '. Then just
reference array location for each cell and output the contents. If it
is empty, fine, but if you assign a string like that, the color will
change.

Both solutions require you to put code at each cell though...
I've never figured out any way around it.

Ex:
<?
$cellStyles = array();
$cellStyles[1][0] = 'style="backgro und-color:#CCCCCC;" ';
?>

<table>
<tr>
<td <?=$cellStyle s[0][0]?>>a</td>
<td <?=$cellStyle s[1][0]?>>b</td>
</tr>
<tr>
<td <?=$cellStyle s[0][1]?>>c</td>
<td <?=$cellStyle s[1][1]?>>d</td>
</tr>
</table>

Oct 18 '06 #2
Hmm toffee <to****@toffee. comwrote:
Does anyone know of a clever way to do this ?
you can use css to show color on clicked cell - bkg color or bkg img but you
will have to remeber in script what cell was clicked
orter solution make make href and set visited option on your bkg color then
you no need script

--
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

2be || !2be $this =mysql_query();
Oct 18 '06 #3
| Both solutions require you to put code at each cell though...
| I've never figured out any way around it.
|
| Ex:
| <?
| $cellStyles = array();
| $cellStyles[1][0] = 'style="backgro und-color:#CCCCCC;" ';
| ?>
|
| <table>
| <tr>
| <td <?=$cellStyle s[0][0]?>>a</td>
| <td <?=$cellStyle s[1][0]?>>b</td>
| </tr>
| <tr>
| <td <?=$cellStyle s[0][1]?>>c</td>
| <td <?=$cellStyle s[1][1]?>>d</td>
| </tr>
| </table>
perhaps this may be easier (if i understood you correctly):
<html>
<style type="text/css">
td
{
background-color : white;
cursor : pointer;
width : 50px;
}
</style>
<script type="text/javascript">
var currentCell;
function colorMe(el)
{
if (!el){ return; }
if (!el.style){ return; }
if (currentCell){ currentCell.sty le.backgroundCo lor = ''; }
currentCell = el;
currentCell.sty le.backgroundCo lor = '#CCCCCC';
}
</script>
<body>
<table>
<tr>
<td onclick="colorM e(this);">a</td>
<td onclick="colorM e(this);">b</td>
</tr>
<tr>
<td onclick="colorM e(this);">c</td>
<td onclick="colorM e(this);">d</td>
</tr>
</table>
<body>
<html>
Oct 18 '06 #4
Hmm Steve <no****@example .comwrote:
perhaps this may be easier (if i understood you correctly):
nope :) he wrote about refresh, and what if some1 block js?

--
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

2be || !2be $this =mysql_query();
Oct 18 '06 #5

".:[ ikciu ]:." <no@mail.comwro te in message
news:eh******** **@news.dialog. net.pl...
| Hmm Steve <no****@example .comwrote:
| perhaps this may be easier (if i understood you correctly):
|
| nope :) he wrote about refresh, and what if some1 block js?

if you're going to ridicule me again, but in this thread now, i suggest that
you learn to COMPREHEND english!!! unless you want me to embarrass you
again. in case you missed it, the OP spoke of MANY things...but THIS is his
question:

<quote>
I would like to make it so that whichever cell was clicked; the background
color is changed
</quote>

so yes, my example does EXACTLY that...fucking moron!
Oct 18 '06 #6
thanks everyone for the suggestions and I didnt mean to start an argument
:-/

Steve - apologies for not making it clearer, but when a user clicks on a
cell the page is indeed refreshed; i just wanted to be able to show which
cell caused the refresh by highlighting it.

kind regards

T

"Steve" <no****@example .comwrote in message
news:Ac******** *******@newsfe0 7.lga...
>
".:[ ikciu ]:." <no@mail.comwro te in message
news:eh******** **@news.dialog. net.pl...
| Hmm Steve <no****@example .comwrote:
| perhaps this may be easier (if i understood you correctly):
|
| nope :) he wrote about refresh, and what if some1 block js?

if you're going to ridicule me again, but in this thread now, i suggest
that
you learn to COMPREHEND english!!! unless you want me to embarrass you
again. in case you missed it, the OP spoke of MANY things...but THIS is
his
question:

<quote>
I would like to make it so that whichever cell was clicked; the background
color is changed
</quote>

so yes, my example does EXACTLY that...fucking moron!


Oct 18 '06 #7
Don't worry about those 2 arguing. They seem to be like the Odd Couple.
I've watched them bicker through 2 threads already within the past 24
hours. Wish they could just all get along...or take it outside...or
something.

As long as you get your solution, this ng proves its worth.

toffee wrote:
thanks everyone for the suggestions and I didnt mean to start an argument
:-/

Steve - apologies for not making it clearer, but when a user clicks on a
cell the page is indeed refreshed; i just wanted to be able to show which
cell caused the refresh by highlighting it.

kind regards

T

"Steve" <no****@example .comwrote in message
news:Ac******** *******@newsfe0 7.lga...
>".:[ ikciu ]:." <no@mail.comwro te in message
news:eh******* ***@news.dialog .net.pl...
| Hmm Steve <no****@example .comwrote:
| perhaps this may be easier (if i understood you correctly):
|
| nope :) he wrote about refresh, and what if some1 block js?

if you're going to ridicule me again, but in this thread now, i suggest
that
>you learn to COMPREHEND english!!! unless you want me to embarrass you
again. in case you missed it, the OP spoke of MANY things...but THIS is
his
>question:

<quote>
I would like to make it so that whichever cell was clicked; the background
color is changed
</quote>

so yes, my example does EXACTLY that...fucking moron!


Oct 18 '06 #8

"toffee" <to****@toffee. comwrote in message
news:eh******** **@news.freedom 2surf.net...
| thanks everyone for the suggestions and I didnt mean to start an argument
| :-/
|
| Steve - apologies for not making it clearer, but when a user clicks on a
| cell the page is indeed refreshed; i just wanted to be able to show which
| cell caused the refresh by highlighting it.
|
| kind regards
|
| T

very good. i actually posted that so you'd flesh out how you wanted the
refresh to run. one way is to use javascript and populate all the data
needed for all the cells and just hide that data in a div in the
html...getting it via js would allow you one trip to the server without the
refresh. as it is, i see you intend not to use js. the solution is fairly
simple...i'll work up a quick example and post it here.

cheers
Oct 19 '06 #9

"Breklin" <br*****@sbcglo bal.netwrote in message
news:1y******** **********@news svr13.news.prod igy.com...
| Don't worry about those 2 arguing. They seem to be like the Odd Couple.
| I've watched them bicker through 2 threads already within the past 24
| hours. Wish they could just all get along...or take it outside...or
| something.

lol. it does seem that way, doesn't it. i've got him plonked so i won't see
further posts.

l8r
Oct 19 '06 #10

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

Similar topics

1
4994
by: Gerg | last post by:
The datagrid has a tablestyle applied to it, and there are DataGridTextBoxColumn and each DataGridTextBoxColumn has an array of DataGridTextBox objects. Private Sub highlight(ByVal str As String) Dim myTextBoxcolumn As DataGridTextBoxColumn Dim myTextBox As DataGridTextBox 'loop through the cells of the datagrid, searching for the string
2
4921
by: J Krugman | last post by:
I have set up an HTML table with clickable cells (the cells contain only text). They work fine, but I would like to give the user some visual feedback to indicate that a cell has been clicked. I'd like this feedback to be the usual highlight on mouseDown, un-highlight on mouseUp, but I can't figure out how to do it. Help? Thanks in advance! jill --
11
4351
by: VK | last post by:
Hi, I'm playing around with tables (TOM vs. DOM etc.) I cannot figure out an effective highlight mechanics for the cells: 1) No problems with: <td ...onMouseOver/Out background change> some text inside </td> 2) <td ...onMouseOver/Out background change>
1
5272
by: Michael Ramey | last post by:
I'm using the following code to highlight the current row: private void Datagrid1_CurrentCellChanged(object sender, System.EventArgs e) { DataGrid1.Select(DataGrid1.CurrentRowIndex); } The entire row is selected, but the cell with cursor in it, shows the grid value as selected. The looks strange. Is there a way to eliminate the cell selection?
2
1610
by: Geraldine Hobley | last post by:
Hello I have a datagrid, called MyDataGrid and I wish to put the focus on a particular cell in order that the user to highlight the fact that the user needs to enter a value in this cell, e.g. I put the message up "Please enter an order number" I then wish to highlight the column MyDataGrid(0,1), but I can't find out how to do this Many thanx in advance Geri
0
1906
by: Islandbuoy | last post by:
Hi all, A VB learner on the loose here - keen as mustard but thoroughly confused !! I wish to change both the Interior Colour Index & Font Colour Index in a specific cell when that cell only is active. There appear to be lots of formulae around to work on every cell in throughout worksheets but nothing that limits the operation to one cell only - say "A3". I hope someone out there can help....
2
2164
cassbiz
by: cassbiz | last post by:
The output I am receiving is not highlighting all of the contents just part. in the below code @line 21 if a certain variable is met I want the cell highlighted. The problem is in the output it is highlighting but only on one cell and not covering the other cells that need to be highlighted. For example, the customer books a room for 3 days. The first day is not highlighting just the 2nd and 3rd. If they book a room for only one day then...
5
2708
by: Dave | last post by:
Is there a way to selectively highlight text in an OverLib popup? I'd like to be able to make some text stand out from the rest of the text that is displayed. I tried using a one-cell table with background set to yellow, but that caused the popup not to work at all (this might be a syntax problem - I haven't been able to find any syntax examples for putting a table inside an OverLib call) Thanks
1
2541
by: dixonjm | last post by:
Hi, I am adding a table dynamically using c# as below:- productCell = new TableCell(); KSSCheckBox checkBox = new KSSCheckBox(); checkBox.ID = string.Format("CheckBox|{0}|{1}", x, product.OwnProductUID); checkBox.Description = "Update"; checkBox.Checked = false; checkBox.Attributes.Add("onClick", "HighLightCell();");
0
8031
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8456
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8443
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8107
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6792
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5971
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3945
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3989
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1309
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.