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

how to retrieve index Position of a <TD>

syedshaffee
hey people,

can someone please suggest me how to retrieve the value of the index position of <TD> at run time to be specific here is the code
Expand|Select|Wrap|Line Numbers
  1. $("#Table_Data tr").click(function(){
  2.    $(this).find(':checkbox').attr('checked', ! $(this).find(':checkbox').attr('checked'));    
  3.    if($(this).find(':checkbox').attr('checked'))
  4.         {
  5.               var index=$(this). 
  6.               var html = '';
  7.     html = $('#clickME td:eq(1)').text();//here i have defined it statically but it needs to be dynamic
  8.     alert(html);
  9.  
  10.  
  11.  
  12.         }
  13.         else
  14.         {
  15.             $(this).removeClass('highlight');
  16.               $(this).addClass('evenrow');
  17.         }
  18. });
my problem:
1) the index value and the text of that index value of <TD> should be according to the users selection meaning i have added a check box in my table

how to apply the same
Jan 20 '12 #1
10 1782
Dormilich
8,658 Expert Mod 8TB
do I interpret it right that the desired number is the value of the checkbox?
Jan 20 '12 #2
No,check value is not required i require the cell value of 2nd row
Jan 20 '12 #3
Dormilich
8,658 Expert Mod 8TB
the index value [...] should be according to the users selection
so which is the user's selection then if not the checkbox value?
Jan 20 '12 #4
for example take a google inbox page i m doing something like that when a user selects a row the 2nd cell value of the row should be displayed in a msgbox
Jan 20 '12 #5
Dormilich
8,658 Expert Mod 8TB
if it's always the second cell of the selected row, it is index number 1.
Jan 20 '12 #6
OK i tried that
Expand|Select|Wrap|Line Numbers
  1. $('#clickME td:eq(1)').text();
but when i going and click the second check box its giving me the same value and one more thing the <TD> is dynamically generated from database so i want that when the user clicks on the second check box the value of that 2<TD> should be displayed the code is here
Expand|Select|Wrap|Line Numbers
  1.   <td  ALIGN="left" VALIGN="top" bgcolor="<%=BgColour%>" NOWRAP><input id="Checkbox1" type="checkbox" /></td>
  2.                 <td ALIGN="left" VALIGN="top" bgcolor="<%=BgColour%>" NOWRAP><%=rstAsset("Asset_id") %> </td>
  3.                 <td  ALIGN="left" VALIGN="top" bgcolor="<%=BgColour%>" NOWRAP><%=rstAsset("invoice_no")%> &nbsp; </td>
  4.                 <td ALIGN="left" VALIGN="top" bgcolor="<%=BgColour%>"> <%= rstAsset("invoice_date") %> &nbsp;</td>
  5.                 <td ALIGN="left" VALIGN="top" NOWRAP bgcolor="<%=BgColour%>"><%=rstAsset("Supplier_Name")%> &nbsp;</td>
  6.                 <td ALIGN="left" VALIGN="top" bgcolor="<%=BgColour%>" NOWRAP><%=rstAsset("Asset_type_description")%> &nbsp;</td>
  7.                 <td ALIGN="left" VALIGN="top" bgcolor="<%=BgColour%>"> <%= rstAsset("assettypesubdesc") %> &nbsp;</td>
  8.                 <td ALIGN="left" VALIGN="top" bgcolor="<%=BgColour%>"> <%= rstAsset("Asset_description") %> &nbsp;</td>
  9.                 <td ALIGN="left" VALIGN="top" NOWRAP bgcolor="<%=BgColour%>"> <%=rstAsset("Asset_Serial_no")%> &nbsp;</td>
  10.                 <td ALIGN="left" VALIGN="top" NOWRAP bgcolor="<%=BgColour%>"><%=rstAsset("Asset_barcode_no")%> &nbsp;</td>
  11.                 <td ALIGN="right" VALIGN="top" NOWRAP bgcolor="<%=BgColour%>"> <%=Formatnumber(rstAsset("Asset_purchase_price"))%></td>
  12.                 <td ALIGN="left" VALIGN="top" bgcolor="<%=BgColour%>"> <%= ucase(rstAsset("statedesc")) %>&nbsp; </td>
  13.                 <td ALIGN="left" VALIGN="top" bgcolor="<%=BgColour%>"> <%= ucase(rstAsset("Department_Desc")) %>&nbsp; </td> 
  14.                 <td ALIGN="left" VALIGN="top" NOWRAP bgcolor="<%=BgColour%>"> <%=rstAsset("Cost_Centre_Code")%> &nbsp;</td>
  15.  
how can i do that
-------------------
|check box| | TD |->when he clicks on the check box
+---------+-+-----+ the value of that TD should be displayed
|check box| | TD |
+---------+-+-----+

can u please suggest me for the same or alternative for the same
Jan 20 '12 #7
Dormilich
8,658 Expert Mod 8TB
but when i going and click the second check box
what second checkbox?

when you said "select a row" this seemed to be a click action on the <tr> since you explicitly denied that a checkbox was used. (and for the records, I don't have a google inbox page to look at for comparison)

the <TD> is dynamically generated from database
that is considered static for JavaScript since the content is created before JS starts up.

besides that, when posting HTML code, use the one you get from the browser (via view source code) as any server-side code is absolutely pointless.
Jan 20 '12 #8
i didn't get u friend
Jan 20 '12 #9
Dormilich
8,658 Expert Mod 8TB
in what regard? mind that the only information I have is the one you give me. the clearer the information, the better I can help.
Jan 20 '12 #10
Finally got it man and working great
Jan 23 '12 #11

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

Similar topics

0
by: Matt Adams | last post by:
I want to move the following <PRE> defintion to a css file: <TABLE><TR><TD><PRE>sample text</PRE></TD> <TD> not predefined font</TD></TR></TABLE> should be <TABLE><TR><TD class=aaa>sample...
32
by: Werner Partner | last post by:
Hier is the problem: http://asterix/sonoptikon.de/artemis/index.php The <h1> and <h2> make their ellbows so broad that in the picture arise borders on top and bottom. The general question is:...
14
by: Zenobia | last post by:
Hello folks, Is it possible to position an item within a <td> element? For instance see below. The table has multiple rows, one for each database record. Each row has 3 hrefs associated with it...
2
by: js | last post by:
I have a table rendered with XSLT. The first column has a radio button controls for user to make a selection for a particular row. All the values in the remaining columns are all concated with a...
4
by: dropdeadster | last post by:
Trying to line up a tic-tac-toe board type grid of images using style= tags to <img inside a table TD but it's not working, I get more like a set of steps, can I get an explanation of what's wrong...
5
by: mahesr | last post by:
I want to match some particular text between <tr>and </tr> or <td>and </td>.... in PHP. like below............ <table><tr> CATEGORY: <td><font face="Verdana" size="1" color="#A000A0"> Wedding...
1
by: test9991014 | last post by:
Hi folks, I've got something like this: <table> <tr> <td>1</td> <td align=center> <input type=text> </td>
7
by: Xiaoyan | last post by:
Hi,everyone: I have a problem now. I can't get the information between the <tr><td> and </td></tr>. for example: I use this regular expression can't get it, I don't know why....
2
by: markszlazak | last post by:
I'm a relatively slow response of table cells changing their background color with mouseover/our in IE6 (Win 2K) but the response is fine (fast) in Firefox. Why? The code is below. Sorry about the...
4
by: harryusa | last post by:
I am trying to center 2 images concentrically which are z-indexed to lay on top of each other making an image with a border from another image that has a transparent center. I need the images to be...
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: 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:
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
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:
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
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...

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.