| Firefox problem |
| mostafa hamdy posted at Thursday, August 17, 2006 8:03 AM |
hi all
I have web page which contains table with ans I set for each row in the table Name and Id attributes,and when I try to access soecific row in the table by name it works very fine with IE but it makes problems with firefox and it display in the alert undefined: the code is listed below
-------------HTML code-----------------------
<table width="50%" bgcolor="#000000">
<tr id="tr1" name="firsttr"><td></td></tr>
<tr id="tr2" name="secondtr"><td></td></tr>
<tr id="tr3" name="thirdtr"><td></td></tr>
</table>
------------------------JS code---------------------------
function myFunction()
{
var trname = document.getElementByid('tr1').name ;
alert(trname);
}
plz if any body can help me in solving this problem plz send me
bets regards
Mostafa |
 |
|
|
| |
| Firefox and IE issues |
| J S replied at Thursday, August 17, 2006 8:10 AM |
This will help u : http://west-wind.com/weblog/posts/1463.aspx |
 |
| |
| Example: |
| Peter Bromberg replied at Thursday, August 17, 2006 9:02 AM |
 | function myFunction()
{
var trname = document.getElementById('tr1').attributes['name'].value;
alert(trname);
} |
 |
| |
| Table Row Does not have a Name Attribute |
| Chad . replied at Thursday, August 17, 2006 9:25 AM |
Hi,
As per W3c Specifications a Table Row does not have a name attribute.
Hence it is not advisable.
You can use the IDs for the same?
Is there any specific constraint that makes you use the name?
Let me know in case I can help you.
-
Chandu |
 |
| |
RE:working code |
| Sushila Patel replied at Thursday, August 17, 2006 12:23 PM |
function myFunction()
{
var trname = document.getElementById('tr1').getAttribute('name') ;
alert(trname);
}
Tested on Firefox and IE |
 |
| |
|
|