Change cell color in a cell when hyperlink is clicked

I have a table across the bottom of my form, when a user clicks a hyperlink in one of the cells, I want the bgcolor of the cell to change.

9/1/2003 10:41:08 AM 93655 articles. 5 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 0

You can use the onClick event of the cell to change its bgcolor property. For example:
<td bgcolor="black" onclick"bgcolor='white';">This is a test!</td>
This uses event propogation to capture the click event which is passed down from the link.

Steven Bey

Recursion: see Recursion
9/1/2003 12:13:50 PM
Don't know what I'm doing wrong, I used your example and it it doesn't want to cooperate.

The bgcolor automatically deafults to the onclick color and does not change when clicked; I also reversed the colors, same results.
9/2/2003 12:04:39 AM

Sorry, there was a slight flaw to my logic (and also a syntax error!). Using hash for the URL will actually refresh the page, so you need to replace it with javascript:void(0). Also include an equals sign inbetween onclick and the opening quote, as below:
<td bgcolor="black" onclick="bgcolor='white';">This is a test!</td>

Steven Bey

Recursion: see Recursion
9/2/2003 10:00:41 AM
Still no dice, it's just not picking up the OnClick. Here's what I used:

<td bgcolor="black" onclick="bgcolor='white';">This is a test!</td>

It fire's my function but the bgcolor stays the same.
9/3/2003 8:53:29 AM

As I explained in my first post, this uses event propogation to work. Putting your function in the href will not propogate the onclick event. You need to keep the javascript:void(0) in but put your function reference in the onclick event:
<td bgcolor="black" onclick="bgcolor='white';">This is a test!</td>

Steven Bey

Recursion: see Recursion
9/3/2003 9:50:08 AM

Similar Artilces:

Change Datagrid cell color based on cell value
I was wondering if there is a way to change the background color of an individual cell in a datagrid based on it's value. (I code in VB) Example: I have a Due Date field and the cells need to be highlighted yellow for all dates that are over 30 days old. Then for all of the dates that are over 60 days old, their cell backgrounds would need to be red. Thanks for the help in advance Dan Take a look @ Change Color of a Column Based on Column Values In your case you can use <Table> tag and change the <td> background color using helper function HTH Sushila ...

change grid cells back color (Cells Blinks)
Dear devs my case is im building a website similar to stocks websites, i used ajax for refreshing issues and gridview for disiplaying data. now the data will change frequently and i want to color the changed data (coloring the cells of changed data). but the problem is i dont know which cell is changed and which one staied remain. thanks for helpingJaffar N. Khalid Hi:   From your description my understanding is that you're using UpdatePanel and a Timer. Is it right? If my understanding is correct you can get the original data before GridView is bound again. Store it in a globa...

Changing a Cells color based on another cells value
We want to change the color of a previous cell based on the value in the current cell. For example, say we are ranking items as they are read into the datagrid. We have several columns of data we want to rank for first and second place. Once we encounter a value that is greater than the previous high value we would like to change the previous high values cell color to yellow and the new high cells color to green. For example column 1 in the following table would have 12 highlighted in green and 10 highlighted in yellow. See the following table. Column 2 would have 11 highlighted green and th...

Change Table Cell color with click
I have been tinkering with this and can't seem to reach a quick solution. I have hyperlinks in a table across the bottom of my form. When a user clicks the hyperlink it loads a page in the frame above it. What I want is when a cell is clicked, for the bgcolor to be different until another cell is selected so the user knows what their last selection was. I am able to make it change colors by adding OnCLick="this.bgColor = 'MyColor'" to the cell, but I can't find anything make it catch when another cell is clicked for the bgcolor to go back normal and change the bgcolor of the newly ...

Changing cell colors in a datagrid based on the information contained in the cell
Any help I can get would be greatly appreciated. I have a datagrid with information in several columns that show the status of certain aspects of a given project. Red for an area in trouble in trouble, yellow for those having problems that could become serious and green for those running as planned. What I would like to do is have the cell color change to correspond to the status of the project. Since the project managers update the status of projects as needed the color would need to change based on the text entered into the cell turning either red, yellow or green to correspond. H...

how do I conditionally change bkg color of datalist cell and make the content of the cell clickable
Hi all, 1) how do I change background color of a datalist cell based on an attribute value (of a xml file) and make the content of the cell clickable ? 2) assuming the datalist is in an iframe. How do I make the cell content value available to another iframe page via clickable/url passing technique?  Thanks Here's how to change the color (BALANCE_COL is the cell index): protected void GridViewFun_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.DataIt...

Changing data grid cell colors based on information contained within the cells #2
I posted the following question the other day and aspdotnetv2 kindly responded with some code. However this seemed to require the use of the repeater control to accomplish my goal. It worked as it should. But if I do this I loose the functionally of the "data grid" that I wanted. Does anyone know a way to accomplish this using the data grid instead of the repeater?? I have a data grid with information in several columns that show the status of certain aspects of a given project. Red for an area in trouble in trouble, yellow for those having problems that could become serious ...

Accessing cell text and changing background color (
 Hello! I am trying to add on to the function below a feature that would change the background color of a row based on the cell values. I basically have 3 cells with data in them ('In Stock, Needed, On Order). If something is not in stock, I want the row to be red, if it's on order I need it to be yellow, and so on. What I am having trouble with is actually accessing the text values of the cells. I thought it was e.Row.Cells[2].Text but this hasn't worked. I am very new to as I usually use C# for this. It seems like any input I give it crashes. Adding a s...

Make Gridview cell value a hyperlink and change color of font conditional
Hello: I have a gridview displaying information about a project.  One of the columns of the record is the unique "id" and another column called "status" is the status of that record (i.e. New, Queue, Approved, etc).  I would like to do the following in VB code behind... If the Status of the record is equals "Queue" then make the font color of the word "Queue" maroon and make the word "Queue" a hyperlink to another page and pass the unique id of that record to that page.  I can get this to work with an edit...

Changing the value of one cell when the user changes the value of another cell
I am using a standard GridView with multiple columns and a SQLDataSource. One column is called Qty and another column is called Date. When the user clicks the Edit button and enters a quantity into the Qty column, I would like to automatically fill in today's date into the Date column...before the user clicks Save. Any ideas on how to do that? Thanks in advance, Rick     You would have to make an asych call, check out ASP.NET AJAX: add a javascript event on the quantity textbox the onchange On the gridviews rowdatabound add this  Protected Sub Gr...

Making a cell editable on clicking the cell
Hi, I am trying to make a cell editable as soon as the user clicks on that particular cell in the .net data grid. Usually, the way we do is, we click the edit button and the cells become editable and two buttons(Update and Cancel) appear. Instead I would like to make this possible without even clicking on the Edit button. There will be only one button (Save) to save the changes done on the grid. Is there any way to do it ? I hope I am clear. Thanks in advance. Prasad P Take a look at the following article, which shows how you can hightlight the row by clicking anywhere in the ro...

Change Color of a cell
I hav one question please.. I want to color a particular cell in a datagrid this can be done?? Regards,Punithkumar  Hi,In RowDataBound event of GridView, you can do this,  protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)    {        if (e.Row.RowType == DataControlRowType.DataRow)        {            e.Row.Cel...

changing color of a cell
hi i have a hypelink within a tablecell. when i click the hyperlink i'd like to change te cell's backcolor. how can do it? i tried ..... <asp:tablecell id=cell1> <asp:hyperlink onclick="cell1.backcolor=green" navigateurl=page.aspx> ..... it doesnt work. can u tell me? thanks a lot   document.getElementById("someId").style..... but not sure you are adding it to that control the correct way.... | Twitter epascarello | LinkedIn hi   thanks <script language="javscript"> function ChangeCellColor(CellElement) {  CellElement...

Changing cell color
I saw a previous question about how to set the color of an individual cell in a TStringGrid, and the solution was to use the GridDrawCell event to do it manually. However I need some help figuring out how to do that exactly... I have tried: Form2->Grid->Canvas->Brush->Color = clRed; Form2->Grid->Canvas->TextOutA(Rect.left,, "Test"); This results in black text with a red background, however I just want the foreground to stay the same and change the text color only. I have also tried: Form2->Grid->Canvas->Pen->Color = clRed; ....

Web resources about - Change cell color in a cell when hyperlink is clicked -

Hyperlink - Wikipedia, the free encyclopedia
A hyperlink points to a whole document or to a specific element within a document. Hypertext is text with hyperlinks. A software system for viewing ...

SA Supreme Court rules Dr Janice Duffy was defamed by Google through its hyperlinks, auto-complete and ...
A FORMER SA Health researcher has won a six-year legal battle against Google, proving she was defamed by the internet giant due to the way it ...

Banned hyperlinks could cost you $11,000 a day
The Australian communications regulator says it will fine people who hyperlink to sites on its blacklist, which continues to be controversially ...

ANALYSIS - Supreme Court hyperlink decision a victory for free speech
A hyperlink by itself should never be seen as 'publication' of other content, the Supreme Court said. But when it comes to libel the court did ...

Review: HyperLink is a great, inexpensive steel bracelet for the Apple Watch
Apple's own stainless steel link bracelet is too expensive for many of us to consider. HyperLink, however, is a less expensive alternative that ...

Apple's 'audio hyperlink' tech can control devices with inaudible sonic pulses
An Apple patent filing published by the U.S. Patent and Trademark Office on Thursday describes a method of encoding hyperlinks into an audio ...

Patent troll sending out invoices for image hyperlinks
A company named Vuestar thinks everyone who links images to pages on the Web …

How Effective Hyperlinks Can Help Your Blog
... link text explain exactly where the link is leading you or does it say something generic like click here ? When I saw Writing Effective Hyperlinks ...

Gmail's Shortcut for Inserting Hyperlinks
... doesn't mean Google shouldn't improve them. Many people complained that Gmail's rich text editor doesn't have a shortcut for inserting hyperlinks ...

Scientology loss keeps hyperlinks legal
The Church of Scientology loses a courtroom battle to compel a Dutch writer and her ISP to remove postings from a Web site, in a ruling that ...

Resources last updated: 1/10/2016 5:33:25 PM