Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Problem with RADIO (created by DOM) in Internet Explorer

Reply
Thread Tools

Problem with RADIO (created by DOM) in Internet Explorer

 
 
Raghuram Banda
Guest
Posts: n/a
 
      10-21-2003
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

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      10-21-2003


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/

 
Reply With Quote
 
 
 
 
obsidian8@hotmail.com
Guest
Posts: n/a
 
      01-17-2005
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

 
Reply With Quote
 
RobG
Guest
Posts: n/a
 
      01-18-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Internet Explorer 8: C:\Program Files\Internet Explorer\iexplore.exe vs C:\Program Files (x86)\Internet Explorer\iexplore.exe Nathan Sokalski Windows 64bit 16 02-22-2010 08:31 AM
[OT: How to broadcast an internet radio on a real radio world wide?] Jan C. Faerber HTML 0 06-30-2009 08:05 AM
internet explorer 7 - Internet Explorer cannot display the webpag sandy j Windows 64bit 0 05-02-2009 02:12 AM
Internet Explorer and radio problem wl Javascript 5 05-17-2005 04:09 AM
Radio button List problem: How to find value of Radio button list's Selected Item using javascript?? Hiten ASP .Net Web Controls 1 05-26-2004 10:32 AM



Advertisments