Contact Us
  
 
 
    SearchSearch   RegisterRegister   Log inLog in 

innerHTML is not working in IE Help?

innerHTML is not working in IE Help?

 
Post new topic   Reply to topic     Forum Index -> JavaScript, DHTML, AJAX
View previous topic :: View next topic  
Author Message
juniormember



Joined: 28 Jun 2008
Posts: 154

PostPosted: Sun Jul 20, 2008 11:41 am    Post subject: innerHTML is not working in IE Help? Reply with quote

Hi

I have code which is working fine in firefox but not working in IE which i am using IE 6 version. I tried all this innerHTML in every way but not working

i am using this code for validation of form of javascript and print error throught innerHTML. But it is throwing error of Object error by IE

but innerHTML working fine in other screens in IE also

Code:

<html>
<head>
<script>
function validate()
{
   document.getElementById("user").innerHTML="";
   document.getElementById("sEmailID").innerHTML="";
     
   if((document.formname.user.value)==""){
     document.getElementById("user").innerHTML="User ID empty";
     document.formname.user.focus();
     return false;
   }
   else if((document.formname.sEmailID.value)==""){
     document.getElementById("sEmailID").innerHTML="Email empty";
     document.formname.sEmailID.focus();
     return false;
   }
}   
</script>   
</head>

<body>
<form name="formname" onsubmit="return validate();">
<input type="text" name="user" /><span id="user"></span><br/>
<input type="text" name="sEmailID" /><span id="sEmailID"></span><br /><br/>
<input type="submit" name="submit" value="submit">

</form>
</body>
</html>


Help if you can
Back to top
View user's profile Send private message
admin
Site Admin


Joined: 24 Aug 2006
Posts: 30

PostPosted: Sun Jul 20, 2008 11:44 am    Post subject: Reply with quote

Everything seem to be fine in this code. Sometimes IE don't allow us to take same name of input box and id name in other tags. so you are taking innerHTML with same name property with input box. Firefox give us seperate one and innerHTML work fine. Try to take different name of div tag other than input box. and run again.
I have tested this code and working fine


Code:

<html>
<head>
<title> </title>
<script>
function validate()
{
   document.getElementById("error_user").innerHTML="";
   document.getElementById("error_sEmailID").innerHTML="";
     
   if((document.formname.user.value)==""){
     document.getElementById("error_user").innerHTML="User ID empty";
     document.formname.user.focus();
     return false;
   }
   else if((document.formname.sEmailID.value)==""){
     document.getElementById("error_sEmailID").innerHTML="Email empty";
     document.formname.sEmailID.focus();
     return false;
   }
}   
</script>   
</head>

<body>
<form name="formname" onSubmit="return validate();">
<input type="text" name="user" /><span id="error_user"></span><br/>
<input type="text" name="sEmailID" /><span id="error_sEmailID"></span><br /><br/>
<input type="submit" name="submit" value="submit">

</form>
</body>
</html>



This is working fine
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> JavaScript, DHTML, AJAX All times are GMT
Page 1 of 1

 
Jump to:  
  Quick Post a Reply Topic
     
  Name (required)  
     
  Email Address (will not be published) (required)  
     
  Subject of topic (required)  
     
   
     
   
     
  Advertisement  
     
 
     


  More Links  
 
JSP Introduction
JSP Setup
Simple JSP Example
JSP Variable
Array Declaration in JSP
JSP Forms and User Input
Form Validation
JSP Cookies
JSP Session Object
Loop, content collection, iterator, conditional check in JSP
JSP Application Object
JSP Include
JSP Response Object
JSP Request Object
JSP Error Handling
JSP File Handling Object
JSP Action Tag
JSP Implicit Objects
JSP Declaration
JSP Directive
JDBC Introduction
JDBC Driver
JDBC Connection
JDBC Prepared/Statement
JDBC ResultSet
JDBC Close Connection object
JDBC Insert
JDBC Display Records
JDBC Update
JDBC Delete
JDBC Sorting
JDBC Query
JDBC Exception
JDBC Add Batch
JDBC Transaction/RollBack