473,326 Members | 2,175 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,326 software developers and data experts.

Row Numbers in Firefox

How do I find the row & column number of the table for a checkbox on
its Onclick event

The following HTML sample works perfect in IE. On click of the
checkboxes, I am displaying the row number and its column number. How
do I manage the same in Firefox?
<html>
<head>
<script language="javascript">
function selectedRow(object,cNumber)
{
while (object.tagName != 'TR')
{
object = object.parentNode;
}
RowNumber = object.rowIndex;
cellNumber = cNumber;
alert(RowNumber + " : " + cellNumber)
}
</script>
</head>
<body>
<table width="20%" border="1" cellpadding="0" cellspacing="0"
bordercolor="#CCCCCC" id=myTable name=myTable>
<tr id="1">
<td width="28%"><input name="r1c1" type="checkbox" id="r1c1"
onClick="selectedRow(this.parentElement,this.paren tNode.cellIndex)">
R1, C1</td>
<td width="32%"><input name="r1c2" type="checkbox" id="r1c2"
onClick="selectedRow(this.parentElement,this.paren tNode.cellIndex)">
R1, C2</td>
</tr>
<tr id="1">
<td><input name="r2c1" type="checkbox" id="r2c1"
onClick="selectedRow(this.parentElement,this.paren tNode.cellIndex)">
R2, C1</td>
<td><input name="r2c1" type="checkbox" id="r2c1"
onClick="selectedRow(this.parentElement,this.paren tNode.cellIndex)">
R2, C1</td>
</tr>
</table>
</body>
</html>

Mar 11 '06 #1
1 2737
Angel wrote:
How do I find the row & column number of the table for a checkbox on
its Onclick event

The following HTML sample works perfect in IE. On click of the
checkboxes, I am displaying the row number and its column number. How
do I manage the same in Firefox?
<html>
<head>
<script language="javascript">
function selectedRow(object,cNumber)
{
while (object.tagName != 'TR')
{
object = object.parentNode;
}
RowNumber = object.rowIndex;
cellNumber = cNumber;
alert(RowNumber + " : " + cellNumber)
}
</script>
</head>
<body>
<table width="20%" border="1" cellpadding="0" cellspacing="0"
bordercolor="#CCCCCC" id=myTable name=myTable>
<tr id="1">
<td width="28%"><input name="r1c1" type="checkbox" id="r1c1"
onClick="selectedRow(this.parentElement,this.paren tNode.cellIndex)">
R1, C1</td>
<td width="32%"><input name="r1c2" type="checkbox" id="r1c2"
onClick="selectedRow(this.parentElement,this.paren tNode.cellIndex)">
R1, C2</td>
</tr>
<tr id="1">
<td><input name="r2c1" type="checkbox" id="r2c1"
onClick="selectedRow(this.parentElement,this.paren tNode.cellIndex)">
R2, C1</td>
<td><input name="r2c1" type="checkbox" id="r2c1"
onClick="selectedRow(this.parentElement,this.paren tNode.cellIndex)">
R2, C1</td>
</tr>
</table>
</body>
</html>


You have "this.parentElement" in the onclick method. You mean
"this.parentNode".

Nige
Mar 11 '06 #2

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

Similar topics

19
by: David | last post by:
Hi all, A while back I asked how to sort an array of strings which would have numerals and I wanted to put them in sequential numerical order. For example: myArray = "file1"; myArray =...
45
by: bobalong | last post by:
Hi I'm have some problem understanding how JS numbers are represented internally. Take this code for an example of weirdness: var biggest = Number.MAX_VALUE; var smaller = Number.MAX_VALUE...
12
by: e271828 | last post by:
Hi, I'm helping to work a developer tool that verifies a given HTML element has a given attribute (e.g., that all LABEL elements have a FOR attribute, all INPUT elements have an ID attribute,...
24
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How can I see in javascript if a web browser accepts cookies?...
1
by: carlg | last post by:
There seem to be plenty of Javascript implemented WYSIWYG editors for editing rich text in a web browser, but I haven't been able to find one that shows line numbers. Even if that was the only...
2
by: RezaRob | last post by:
I've tried Firebug and the Error Console, and neither gives me file/ line number for "uncaught exception: java.lang.ClassCastException". I'm using Firefox 2.0.0.4. Many thanks. Reza.
4
by: Vlinder | last post by:
I'm completely new to PHP (jumped ship this week from MSAccess and ASP to MySql and PHP) and I'd appreciate some help with leading zeros in telephone numbers. I've got a field with type...
2
by: Cameron McCormack | last post by:
Hi. When viewing this page in Firefox 2, http://mcc.id.au/temp/2007/list the position of the numbers on each list item isn't aligned with the first line of text in the <li>. This is...
2
by: arnuld | last post by:
Again, my friend, who does not much access to internet, has given me a working program and I need your views on improvement and design. I put some error checking but my experience with C has made...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.