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

createElement not working in IE

Hi,

I wrote a javascript code as follows

Expand|Select|Wrap|Line Numbers
  1. function fun1()
  2. {
  3.                 var element = document.createElement('input');
  4.         element.type='checkbox';
  5.         element.checked='checked';
  6.                 body.appendChild(element);
  7.  
  8.  
  9. }
this code is working fine in Firefox but in IE the checkbox is creating but it is unchecked.
I want a checked check box(It is coming in firefox)

Help me out please
Oct 10 '08 #1
3 1604
Dormilich
8,658 Expert Mod 8TB
try:
element.checked = true;

regards
Oct 10 '08 #2
thanks for response

I got it.It can be done just by writing
element.checked='checked';
after append
as follows the complete code:

Expand|Select|Wrap|Line Numbers
  1. function fun1()
  2. {
  3.  
  4. var element = document.createElement('input')
  5.         element.type='checkbox';
  6.         body.appendChild(element);
  7.         element.checked='checked';
  8. }
Oct 10 '08 #3
acoder
16,027 Expert Mod 8TB
That's correct, or you can use the defaultChecked property. See Dynamically appended checked checkbox does not appear checked.
Oct 10 '08 #4

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

Similar topics

25
by: kie | last post by:
hello, i have a table that creates and deletes rows dynamically using createElement, appendChild, removeChild. when i have added the required amount of rows and input my data, i would like to...
2
by: kie | last post by:
hello, when i create elements and want to assign events to them, i have realised that if the function assigned to that element has no parameters, then the parent node values can be attained. ...
2
by: Andrew Poulos | last post by:
I'm having some trouble getting document.createElement to work with IE 5. Is this because it's unsupported? And, if it is unsupported, is using innerHTML a valid workaround? Andrew Poulos
6
by: mitch | last post by:
It seems like if you create an element dynamically with createElement() and then try to get it later with getElementsByName() it's found in Firefox but not in IE. Here's an example program. Is...
1
by: k386 | last post by:
I am having trouble creating a hidden form field, or least having it accessible from getElementById. Rough overview: I am reading an XML file through XMLhttpRequest and outputting each item...
10
by: webEater | last post by:
Hello, I try the following in Firefox and other modern browsers: window.addEventListener('load', function() { document.title = CSS.getClass('fontSize'); var div = document.createElement('div');...
3
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table...
13
Atli
by: Atli | last post by:
Hi everybody. I'm making a Javascript system to build tables, so I can view large tables in smaller pieces. I use the "document.createElement" and "appendChild" methods to create and remove...
23
by: vunet | last post by:
It is recommended by some sources I found to create IFrames in IE using document.createElement('<iframe src="#">') instead of document.createElement('iframe'). Why and what browser versions to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.