473,388 Members | 1,391 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,388 software developers and data experts.

Highlighting a Linkbutton in javascript onclick

hi all, i have 4 link buttons.all of them opens a popup window. i want when i click on button it gets highlited.
pls help. its urgent.

Neel.
Mar 25 '09 #1
6 3306
RamananKalirajan
608 512MB
onclick of that button just change the class of that button.. so that it looks like highlighted...

ex:

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  3. <HEAD>
  4. <TITLE> New Document </TITLE>
  5. <META NAME="Generator" CONTENT="EditPlus">
  6. <META NAME="Author" CONTENT="">
  7. <META NAME="Keywords" CONTENT="">
  8. <META NAME="Description" CONTENT="">
  9. <style type="text/css">
  10. .normal{
  11.     background-color: #999999;
  12. }
  13. .highlight{
  14.     background-color: #FF3333;
  15. }
  16. </style>
  17. <script type="text/javascript">
  18.     function highlightThis(ths)
  19.     {
  20.        for(var i=1;i<=4;i++)
  21.        {
  22.          var tempId = "select"+i;
  23.          if(ths.id==tempId)
  24.          {
  25.              document.getElementById(tempId).className = "highlight";
  26.          }
  27.          else
  28.          {
  29.             document.getElementById(tempId).className = "normal";
  30.          }
  31.         }
  32.     }
  33. </script>
  34. </HEAD>
  35. <BODY>
  36. <table width="100%" cellspacing="0" cellpadding="3px">
  37.     <tr>
  38.         <td>
  39.                 <input type="button" value="Select1" id="select1" name="select1" class="normal" onclick="highlightThis(this)">
  40.         </td>
  41.         <td>
  42.                 <input type="button" value="Select2" id="select2" name="select2" class="normal" onclick="highlightThis(this)">
  43.         </td>
  44.         <td>
  45.                 <input type="button" value="Select3" id="select3" name="select3" class="normal" onclick="highlightThis(this)">
  46.         </td>
  47.         <td>
  48.                 <input type="button" value="Select4" id="select4" name="select4" class="normal" onclick="highlightThis(this)">
  49.         </td>
  50.     </tr>
  51. </table>
  52. </BODY>
  53. </HTML>
This is just an example.. you can do it n no.. of ways...

Regards
Ramanan Kalirajan
Mar 25 '09 #2
thanx a lot Ramanan it works.
Mar 26 '09 #3
RamananKalirajan
608 512MB
What i have given is just an example and it is the basic way of doing highlighting.. u can try your own and make it better...


Regards
Ramanan Kalirajan
Mar 26 '09 #4
Dormilich
8,658 Expert Mod 8TB
@RamananKalirajan
e.g. using "this" inside the function:
Expand|Select|Wrap|Line Numbers
  1.     function highlightThis()
  2.     {
  3.        for(var i=1;i<=4;i++)
  4.        {
  5. // reset all class names to "normal"
  6.          document.getElementById("select"+i).className = "normal";
  7.        }
  8. // set current class name to "highlight"
  9.        this.className = "highlight";
  10.     }
Mar 26 '09 #5
RamananKalirajan
608 512MB
Thanks Dormilich, 'this' keyword.. using it it simplifies more than what i had did so far.. I will follow this way of doing things...

Regards
Ramanan Kalirajan
Mar 27 '09 #6
Dormilich
8,658 Expert Mod 8TB
it took me quite a while to understand how OOP works in Javascript.
Mar 27 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Matt Law | last post by:
Hi All, Ive just attempted to use a <ASP:LinkButton> on a ASCX User Control. The .NET system produces the HTML/Javascript that doesnt work... Now before you all scream OnCommand, OnClick...
6
by: Al Cohen | last post by:
I'm using a LinkButton to call some code, then do a redirect. The code does some queries, sends some emails, and takes a few moments before the redirect is performed. I'd like to disable my...
4
by: sef | last post by:
i have a server-side script that executes this: linkbutton1.Attributes.Add("onClick", "linkClicked();"); the client-side code has an html image control <img id="image1"> the client-side...
2
by: Dave | last post by:
Hi, I have a datagrid with a Templated column below. I want to execute some javascript before the postback to show a hidden "div" tag with static message of "Please Wait..." since the query takes...
5
by: George Durzi | last post by:
I currently have an href inside of an asp:repeater <a href='<%# String.Concat("PDFReader.aspx?id=", DataBinder.Eval(Container.DataItem, "ProductUniqueId")) %>' target="_blank">View</a> ...
5
by: Steve Harclerode | last post by:
Here's some code that I'm using to create a simple list of logical drive letters (my web application impersonates a user). I'm finding that my event handler doesn't fire. Can anyone give me a hint...
3
by: Learner | last post by:
Hello, I have two buttons on one of my VehicleDetails.aspx page. Obiviously these two buttons takes the user to two different pages. Now my client is interested in having a linkbutton instead of...
3
by: John | last post by:
Hi I have been trying to change the css class of a linkbutton without succes ( I dont want to change the cssclass property). Maybe somebody knowshow to do this?? th.John <%@ Page...
7
by: Leif902 | last post by:
After much searching of google, the closest I can find is highlighting search terms... however, this is not what I wanted to do. Does anyone know how to parse through a specific element (lets say...
1
by: David C | last post by:
I have posted this question, which I think is very simple on several sites, and nobody seems to know what I am talking about. At my wits end here. Please help. I am putting together a site...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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
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
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...

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.