473,657 Members | 2,481 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DOM innerHTML "runtime error" in IE 6

4 New Member
Hi,

The error I am describing occurs with the script I've pasted below.

It's a validator for form fields and prints a message into a span tag located beside the empty input tag.

I have hard coded the error message to be printed in a specific span tag for testing. --> "<span id="name">www</span>"

When this span tag is positioned BEFORE the input tag it works fine but when I place it after (which is the layout I want) it stops working and gives a "runtime error" message.

Any ideas what is causing this?

Any help would be greatly appreciated.
Thanks in advance, Will



Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3.     <head>
  4.  
  5.         <script type="text/javascript">
  6.  
  7.             function validate_form()
  8.             {    
  9.  
  10.                 var x;
  11.                 for (i=0; i<document.registerForm.elements.length; i++)
  12.                 {
  13.                      x = document.registerForm.elements[i];
  14.  
  15.                     if (x.type != "button" && x.type != "submit" && x.type != "hidden" && x.value == "")
  16.                     {
  17.                         //var fieldName = x.name;
  18.                         var obj=document.getElementById('name');
  19.                         if(obj){
  20.                          alert("found");
  21.                         }
  22.  
  23.                         obj.innerHTML = "Visit W3Schools";
  24.  
  25.                         alert("false");        
  26.                     }
  27.  
  28.                 }
  29.  
  30.                 alert("true");    
  31.  
  32.             }
  33.         </script>
  34.     </head>
  35.     <body>
  36.  
  37.                 <form name="registerForm"  >
  38.  
  39.                     <table>
  40.  
  41.                     <tr><td>Name:</td><td>   <input name="name" type="text" size="35" />   <span id="name">www</span> </td></tr>
  42.  
  43.  
  44.                     <tr><td>Age:</td><td><input name="age" type="text" size="35" /><span id="age"></span></td></tr>
  45.  
  46.  
  47.                     <tr><td>Phone:</td><td><input name="phone" type="text" size="35" /><span id="phone"></span></td></tr>
  48.  
  49.  
  50.                     <tr><td>Email:</td><td><input name="email" type="text" size="35" /><span id="email"></span></td></tr>
  51.  
  52.  
  53.                     <tr><td colspan="2"><br/><br/><input type="button" onclick="validate_form()"  /></td></tr>
  54.  
  55.                     </table>
  56.                 </form>
  57.  
  58.     </body>
  59. </html>
Jan 24 '08 #1
1 2622
acoder
16,027 Recognized Expert Moderator MVP
If this is occurring in IE6 only, it will most likely be caused by the "name" id. Change it to something else, e.g. "nameValidation ".
Jan 25 '08 #2

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

Similar topics

4
13750
by: KathyB | last post by:
I have the following script in an html page: function goToPosition() { varGoTo = document.write(document.cookie("Position")); document.scrollTo(0, varGoTo); } </head> <body onload="goToPosition()">
1
3742
by: AA Arens | last post by:
To have the first character of a fiels capitalized AfterUppdate, I used the following script: Me!City = UCase$(Left$(Me!City, 1)) + Mid$(Me!City, 2) UCase (Left(Me!City, 1)) + Mid(Me!City, 2) It works and also when I do not fill anything by ignoring this field when I jump from one field to antoher with the TAB button. I only get a script error when I fill someting in the field and then
0
1562
by: Sean OConnor | last post by:
I have three servers, public web server (e.g. web1), file server (file1), and web services server (service1). web1 is in the DMZ and file1 and service1 are internal. I'm calling the webservices from an ASP page using the Microsoft SOAP Toolkit 2.0. I'm seting impersonation in my web.config using an service account that has the appropriate permissions. When I call the services from an ASP page on service1 everything works correctly. However,...
2
4380
by: hardrock | last post by:
Hello! I'm working with the prototype library version 1.4.0 and having a strange error lately. When I want to make an Ajax.Updater call, it basically works. But as soon as I put the call into a function, so that I can call it from a popup, I get the error: "html has no properties" (in Firefox)
7
38002
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement using innerHTML. Now, I've researched this problem on the web, and found many references to it, but none of them quite addressed my specific situation, and since my experience with JavaScript is limited, I was not able to adapt the solutions I...
10
13300
RMWChaos
by: RMWChaos | last post by:
WinVista/IE7 I am getting some weird errors only in IE7, but not in FF2.0.0.8 or NN9. It even happens on this website when I click "Sign In". The error is: "A Runtime Error has occurred." "Line:xxx" "Error: Object expected" and Debug says: "Microsoft JScript runtime error: Object expected."
0
2303
by: syedsarfaraz | last post by:
Hi There! Could anybody please help regarding the below issue. We had a COM+ component deployed on Windows 2000/NT machine it was working fine, I mean when it was being invoked from other machines it was creating object and was serving the purpose. Recently as an upgrade we moved all the COM+ component from Windows 2000/NT to WINDOWS 2003 and now when we are trying to invoke that component its throwing "Runtime Error-429 ActiveX Component...
1
3135
by: aloksingh83 | last post by:
This error coming when i am using telerik grid.It works fine in asp.net grid what i am trying to do is taking values from textbox and show in grid view... here is the code: <script language="javascript" type="text/javascript"> function AddItems() { var lgrd = document.getElementById('<%=RadGrid1.ClientID%>'); var ltxtSystemId = document.getElementById('<%=txtSystemId.ClientID%>'); var...
1
3384
by: itxharsh | last post by:
/* While running the program a runtime error occurs."glibc detected" followed by a lot of memory address/instruction errors. Please help rectify this error.*/ /*Header file:"nonpreemptive.h" is as follows: #define C_OR_CPP 2 // Change value to 1 here if you are submitting a C solution for this problem. // Change value to 2 here if you are submitting a C++ solution for this problem. void dsmain();
0
8306
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.