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

Javascript Problem in Firefox

Dear Members,

I am going to create the online form creation in html with javascript, i have a problem with the following code, i got this code from internet, the following script only works in IE but it doesn't work in other browser like (Firefox and Opera), i don't know what's the problem with code. If anybody know the solution let me know...



Expand|Select|Wrap|Line Numbers
  1. <html>
  2.     <head>
  3.         <title>Adding and Removing Rows</title>
  4.         <script language="javascript">
  5.  
  6.             //add a new row to the table
  7.             function addRow()
  8.             {
  9.                 //add a row to the rows collection and get a reference to the newly added row
  10.                 var newRow = document.all("tblGrid").insertRow();
  11.  
  12.                 //add 3 cells (<td>) to the new row and set the innerHTML to contain text boxes
  13.  
  14.                 var oCell = newRow.insertCell();
  15.                 oCell.innerHTML = "<input type='text' name='t1'>";
  16.  
  17.                 oCell = newRow.insertCell();
  18.                 oCell.innerHTML = "<input type='text' name='t2'>";
  19.  
  20.                 oCell = newRow.insertCell();
  21.                 oCell.innerHTML = "<input type='text' name='t3'> &nbsp;&nbsp;<input type='button' value='Delete' onclick='removeRow(this);'/>";            
  22.             }
  23.  
  24.             //deletes the specified row from the table
  25.             function removeRow(src)
  26.             {
  27.                 /* src refers to the input button that was clicked.    
  28.                    to get a reference to the containing <tr> element,
  29.                    get the parent of the parent (in this case case <tr>)
  30.                 */            
  31.                 var oRow = src.parentElement.parentElement;        
  32.  
  33.                 //once the row reference is obtained, delete it passing in its rowIndex            
  34.                 document.all("tblGrid").deleteRow(oRow.rowIndex);        
  35.             }
  36.  
  37.         </script>
  38.     </head>
  39.     <body>
  40.  
  41.         <!-- sample table grid with 3 columns and 4 rows that are presented by default -->
  42.         <table id="tblGrid" style="table-layout:fixed">
  43.             <tr>
  44.                 <td width="150px">Field1</td>
  45.                 <td width="150px">Field2</td>
  46.  
  47.                 <td width="250px">Field3</td>
  48.             </tr>
  49.             <tr>
  50.                 <td><input type="text" name="t1" /></td>
  51.                 <td><input type="text" name="t2" /></td>
  52.                 <td><input type="text" name="t3" /> &nbsp;&nbsp;<input type="button" value="Delete" onclick="removeRow(this);" /></td>
  53.             </tr>
  54.             <tr>
  55.  
  56.                 <td><input type="text" name="t1" /></td>
  57.                 <td><input type="text" name="t2" /></td>
  58.                 <td><input type="text" name="t3" /> &nbsp;&nbsp;<input type="button" value="Delete" onclick="removeRow(this);" /></td>
  59.             </tr>
  60.             <tr>
  61.                 <td><input type="text" name="t1" /></td>
  62.                 <td><input type="text" name="t2" /></td>
  63.                 <td><input type="text" name="t3" /> &nbsp;&nbsp;<input type="button" value="Delete" onclick="removeRow(this);" /></td>
  64.  
  65.             </tr>
  66.             <tr>
  67.                 <td><input type="text" name="t1" /></td>
  68.                 <td><input type="text" name="t2" /></td>
  69.                 <td><input type="text" name="t3" /> &nbsp;&nbsp;<input type="button" value="Delete" onclick="removeRow(this);" /></td>
  70.             </tr>
  71.         </table>
  72.         <hr>
  73.  
  74.         <input type="button" value="Add Row" onclick="addRow();" />
  75.         <hr>
  76.  
  77.     </body>
  78.  
  79.  
  80. </html>


Thanks in Advance,



V. Prasath
Apr 6 '09 #1
2 1855
dmjpro
2,476 2GB
"document.all" does not work in Mozilla.
Always try yo follow the W3C specification for JavaScript.
That would be working in all browsers ;)
Apr 6 '09 #2
acoder
16,027 Expert Mod 8TB
In case you're wondering what the standard method is, it's document.getElementById() with a valid ID.
Apr 6 '09 #3

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

Similar topics

12
by: Howard Kaikow | last post by:
Yesterday, I decided to try Firefox. I've encountered a behavior that is either a bug in Firefox or a bug in my Javascript code. I'll try to explain the problem, hoping that this newsgroup can...
5
by: LRW | last post by:
(Sorry if this is a repost...my newsreader keeps crashing on the posting--I don't know if the message going out or not) For some reason this javascript just won't work in Firefox. It works fine...
13
by: John Smith | last post by:
I am using IE 6.0 from http://www.javaworld.com/javaworld/jw-07-1996/jw-07-javascript-p2.html I gather that "If you need to test a number of command lines, you can reduce the keystrokes by...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
4
by: lmarceglia | last post by:
Hi, I have this website that doesn't work in Firefox 1.5: www.pianetaluca.com The HTML source is: <TITLE>PianetaLuca</TITLE> </HEAD>
7
by: Coder | last post by:
Hi I have the following code in java script, it is not giving proper output in FIREFOX but running fine in IE... can anybody help me out to make this run in FIREFOX . <script...
11
by: minnesotti | last post by:
Hi there, I subscribed to a photographic pictures-hosting website which is heavy on JavaScript. My preferred latest browser Mozilla Firefox does not work with it -- no pictures are displayed and...
8
by: Matt Kruse | last post by:
http://news.zdnet.com/2100-1009_22-6121608.html Hackers claim zero-day flaw in Firefox 09 / 30 / 06 | By Joris Evers SAN DIEGO--The open-source Firefox Web browser is critically flawed in...
16
by: Eric | last post by:
I have a user of a web application written in Java/JSP that is unable to login to the site simply because certain links on the page do not run when they are clicked. Other popups using Javascript...
12
by: tim | last post by:
I am using foldoutmenu 3 and am having problems with viewing my menus in firefox. On my sub3 menus i have more than one line of text in some places. firefox does not recognise that there is more...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.