473,402 Members | 2,072 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,402 software developers and data experts.

Problem with RADIO (created by DOM) in Internet Explorer

Hi All,

The following is the function I used to create RADIO buttons using DOM.
It works fine with Netscape but not with IE.
function addGroup3Radio() {
var cellId = document.getElementById("cell1");
for(var i=0; i < arrData.length; i++) {
var objRadItem = document.createElement("input");
objRadItem.type = "radio";
objRadItem.name = "radGroup";
objRadItem.id = "idrad_" + i;
objRadItem.value = arrData[i][0];

if(i == 1) {
objRadItem.defaultChecked = true;
objRadItem.checked = true;
}
var objTextNode = document.createTextNode(" " + arrData[i][1]);
var objLabel = document.createElement("label");
objLabel.htmlFor = objRadItem.id;
objLabel.appendChild(objRadItem);
objLabel.appendChild(objTextNode);

var objBreak = document.createElement("br");

cellId.appendChild(objLabel);
cellId.appendChild(objBreak);
}
document.forms["FirstFormName"].addRadio.disabled = true;
}

Can any one help me to come out of this problem.

Thanks in advance
Raghuram Banda

Jul 20 '05 #1
3 11186


Raghuram Banda wrote:
The following is the function I used to create RADIO buttons using DOM.
It works fine with Netscape but not with IE.
function addGroup3Radio() {
var cellId = document.getElementById("cell1");
for(var i=0; i < arrData.length; i++) {
var objRadItem = document.createElement("input");
objRadItem.type = "radio";
objRadItem.name = "radGroup";
objRadItem.id = "idrad_" + i;
objRadItem.value = arrData[i][0];

if(i == 1) {
objRadItem.defaultChecked = true;
objRadItem.checked = true;
}
var objTextNode = document.createTextNode(" " + arrData[i][1]);
var objLabel = document.createElement("label");
objLabel.htmlFor = objRadItem.id;
objLabel.appendChild(objRadItem);
objLabel.appendChild(objTextNode);

var objBreak = document.createElement("br");

cellId.appendChild(objLabel);
cellId.appendChild(objBreak);
}
document.forms["FirstFormName"].addRadio.disabled = true;
}


What is not working with IE? I guess the radio buttons are inserted
fine, the only thing that IE/Win doesn't support is then to allow access to
document.forms.formName.elements.radGroup
as documented at

http://msdn.microsoft.com/workshop/a...ies/name_2.asp
which explains that you cannot set name on elemens created dynamically
with createElement. The suggestion there is to use the IE only
document.createElement('<input type="radio" name="radGroup">')

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Martin,

I tried your solution for the radio buttons and it worked like a charm!
I must have looked at every posting on this site for javascript and
radio buttons and yours is the only one that worked. Many thanks!
Melvin Morris

Jul 23 '05 #3
ob*******@hotmail.com wrote:
Martin,

I tried your solution for the radio buttons and it worked like a charm!
I must have looked at every posting on this site for javascript and
radio buttons and yours is the only one that worked. Many thanks!
Melvin Morris


So because IE doesn't implement the W3C DOM correctly, you will use an
IE-only method to do something that is well supported on most other
browsers, and certainly all the other mainstream ones?

What was wrong with the more widely supported innerHTML solution
proposed yesterday?

You could try detecting IE and creating elements using their
innerText-like solution, but innerHTML is pretty widely supported and
would not require such silliness.

--
Rob
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: esrkq | last post by:
Hi, I am looking at a way to return IP related information of a visitor loading a web page and found the following snippet of code: if(navigator.javaEnabled() && (navigator.appName !=...
8
by: Shock | last post by:
Hello everyone, I am having a problem with the program below. I have isolated the problem to the onclick event that is located throughout arrQuestions. The onclick event refers to a function...
3
by: The Pritchard | last post by:
I want the user to be able to save the information displayed on a dynamically created page. When I write a script like the following: <SCRIPT> winNew = window.open("","test");...
6
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It...
8
by: wl | last post by:
Hi, I have a radiobutton group in HTML in a form: Sex: <input type="radio" name="Sex" value="male">Male <input type="radio" name="Sex" value="female">Female <input type="radio" name="Sex"...
5
by: sam | last post by:
Hi all, I am dynamically creating a table rows and inerting radio buttons which are also dynamically created. Everything works fine in Firefox as expected. But I am not able to select radio...
3
by: The alMIGHTY N | last post by:
I have a set of radio buttons that are not clickable in Internet Explorer. I dynamically generated them using DOM functions. The arrValues array below stores integers. obj4 =...
7
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...
2
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.