473,383 Members | 1,978 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,383 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 11184


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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...

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.