473,804 Members | 3,163 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.getEle mentById("cell1 ");
for(var i=0; i < arrData.length; i++) {
var objRadItem = document.create Element("input" );
objRadItem.type = "radio";
objRadItem.name = "radGroup";
objRadItem.id = "idrad_" + i;
objRadItem.valu e = arrData[i][0];

if(i == 1) {
objRadItem.defa ultChecked = true;
objRadItem.chec ked = true;
}
var objTextNode = document.create TextNode(" " + arrData[i][1]);
var objLabel = document.create Element("label" );
objLabel.htmlFo r = objRadItem.id;
objLabel.append Child(objRadIte m);
objLabel.append Child(objTextNo de);

var objBreak = document.create Element("br");

cellId.appendCh ild(objLabel);
cellId.appendCh ild(objBreak);
}
document.forms["FirstFormN ame"].addRadio.disab led = true;
}

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

Thanks in advance
Raghuram Banda

Jul 20 '05 #1
3 11205


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.getEle mentById("cell1 ");
for(var i=0; i < arrData.length; i++) {
var objRadItem = document.create Element("input" );
objRadItem.type = "radio";
objRadItem.name = "radGroup";
objRadItem.id = "idrad_" + i;
objRadItem.valu e = arrData[i][0];

if(i == 1) {
objRadItem.defa ultChecked = true;
objRadItem.chec ked = true;
}
var objTextNode = document.create TextNode(" " + arrData[i][1]);
var objLabel = document.create Element("label" );
objLabel.htmlFo r = objRadItem.id;
objLabel.append Child(objRadIte m);
objLabel.append Child(objTextNo de);

var objBreak = document.create Element("br");

cellId.appendCh ild(objLabel);
cellId.appendCh ild(objBreak);
}
document.forms["FirstFormN ame"].addRadio.disab led = 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.elemen ts.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.create Element('<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*******@hotma il.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
7641
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 != "Microsoft Internet Explorer")) { vartool=java.awt.Toolkit.getDefaultToolkit(); addr=java.net.InetAddress.getLocalHost(); host=addr.getHostName();
8
3690
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 and passes it two parameters. For the life of me I cannot figure out what the error is, but one occurs everytime I click a &%*$&# radio button. Also, the function only alerts the user immediately as to what question/answer they clicked. I am...
3
1727
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"); winNew.document.writeln("Hello World!"); winNew.document.close(); winNew.focus();
6
3338
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 is possible to Add and Delete rows - Some cells have special attributes (readonly and events) Here's a snippet of the code:
8
2422
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" value="unknown">Unknown<br>
5
12555
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 buttons in IE. It does not even throw any errors. I have searched over the net but could not find anyhelp. Hope some experts here could help me. Here is part my code that dynamically generates the radio buttons, I cannot paste the entire code as it is...
3
5255
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 = document.createElement("input"); obj4.name = "f0"; obj4.type = "radio"; obj4.value = 1;
7
38029
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...
2
3158
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 message as in alert box as " Internet Explorer cannot open the Internet site http://google.citycarrentals.com.au/viewalllocations.php . Operation aborted". It is working in Mozilla . Here i mentioned my code . I am facing this problem several...
0
9585
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
10586
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10323
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,...
0
9161
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
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
5525
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...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4301
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
3823
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.