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

My alert box displays the number of times the user clicks on it

syedshaffee
hey,
the code i written is displays me the number of time i click on it here is the code
Expand|Select|Wrap|Line Numbers
  1. $(document).ready(function () {    
  2.     //assigning alternative row style
  3. $("#Table_Data tr:even").addClass("evenrow");
  4. $("#Table_Data tr:odd").addClass("oddrow"); 
  5.  $("#Table_Data tr:even").click(function(){
  6.    $(this).find(':checkbox').attr('checked', ! $(this).find(':checkbox').attr('checked'));    
  7.    if($(this).find(':checkbox').attr('checked'))
  8.         {
  9.             var html = '';
  10. $('#Table_Data td').bind("click",function(event) {
  11.     html = $(this).text();
  12.     alert(html);
  13.     $(this).unbind(event)
  14. });
  15.  
  16.         }
  17.         else
  18.         {
  19.             $(this).removeClass('highlight');
  20.               $(this).addClass('evenrow');
  21.         }
  22. });
  23. $("#Table_Data tr:odd").click(function(){
  24.     $(this).find(':checkbox').attr('checked', !$(this).find(':checkbox').attr('checked'));   
  25.     if($(this).find(':checkbox').attr('checked'))
  26.         {
  27.         $('#Table_Data td').click(function() {
  28.     html = $(this).text();
  29.     alert(html);
  30. });
  31.  
  32.              /** $(this).removeClass('oddrow');
  33.               $(this).addClass('highlight');*/
  34.         }
  35.         else
  36.         {
  37.             $(this).removeClass('highlight');
  38.               $(this).addClass('oddrow');
  39.         }
  40. });
  41. });
  42.  
Jan 18 '12 #1
8 1532
Dormilich
8,658 Expert Mod 8TB
and what is the problem with that?
Jan 18 '12 #2
sorry the problem is that it displays me the data the number of times its clicked eg if i click on it once it displays once and if i click on it the second time it displays me the tiwce
Jan 18 '12 #3
Dormilich
8,658 Expert Mod 8TB
and what is it supposed to display?
Jan 18 '12 #4
it should display Only once when the user clicks on the tabledata of a table row
Jan 18 '12 #5
Dormilich
8,658 Expert Mod 8TB
then you need to remove the event listener in the first click action.
Jan 18 '12 #6
If possible can u please provide me the JQuery of it i m using IE 6 and a platform of .net2.0 for asp
Jan 18 '12 #7
Dormilich
8,658 Expert Mod 8TB
I do not hand out code. I only help in the process.
Jan 18 '12 #8
OK removed the event handler and its working fine now the problem is that that the checkbox is already checked here is the code

Expand|Select|Wrap|Line Numbers
  1. $("#Table_Data tr").find(':checkbox').attr('checked', ! $(this).find(':checkbox').attr('checked'));    
  2.    if($(this).find(':checkbox').attr('checked'))
  3.         {
  4.               var html = '';
  5. $(' #Table_Data td').click(function() {
  6.     html = $(this).text();
  7.     alert(html);
  8. });
  9.  
  10.         }
  11.         else
  12.         {
  13.             $(this).removeClass('highlight');
  14.               $(this).addClass('evenrow');
  15.         }
  16. });
i want that the check box should be unchecked when loaded can u pls suggest me what to do? and thanx for the suggestion before
Jan 19 '12 #9

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

Similar topics

2
by: Asit | last post by:
How can i know when user clicks X button of the browser ? I have to write some code when user clicks X button of browser. What is the event for capturing this event ? Help needed ASAP. Asit
4
by: santa19992000 | last post by:
can I use scanf to get input (some times user enters input sometimes not, just hit keyboard)?. It displays to enter IP address, if user wants to change, then he enters, otherwise he hits keyboard,...
7
by: Sandy | last post by:
Hello - I have a form that when submitted checks the database and if the username is already taken, a label shows indicating same. I need to make that label NOT visible after the user clicks...
2
by: jburkle | last post by:
The following is the onclick method called when the "Renew" button is clicked by the user in my Windows application: ..... Private Sub cmdRenew_Click(ByVal eventSender As System.Object, ByVal...
1
by: Mossman | last post by:
Hello, I will discuss at a high level what is happening on an ASP.NET web page I developed a year ago in ASP.NET using Visual Studio 2003 and currently support. I have an ASP.NET web page...
2
by: polocar | last post by:
Hi, suppose that you have a C# form with two buttons, that are the classical "btnOk" and "btnCancel" (besides them, of course in the form there can be many other controls). When the user clicks...
1
by: sowen | last post by:
I am using the ExtensibleDialog to create a dialog for our internal program use. We want the user select some items in our own controls, and then generate the filename to the textbox. But that is...
5
by: phpbeginner | last post by:
Hello again. My question is: Let's suppose that a user clicks on a button. When this button is pressed I want to have a few text boxes appear for the user to fill in. These fields must appear on...
1
by: Sudarhan | last post by:
Hello frnds I have created a webbased form using asp and javascript .. while submitting the form i am validating the fields in the form .it validates the field and returns alert message. but when...
1
by: swetha123 | last post by:
hello, Can any one please tell me I am Using php,Mysql,CSS to build my site In my database i have small images and large images i am show the small images to the right of the main container...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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.