SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Radio buttons created with DOM are not working in IE

    I have a function to create a set of radio buttons using the DOM. I am passing four parameters: father, radio name, array of array (with value & display) & initial checked value. It works OK with FF but with IE 6, it dows not respond to the mouse click. This function is using agregaHijo (using xAppendChild) and agregaNodoTexto (using createTextNode and xAppendChild). Next, the function:

    preparaRadio: function (nodoPadre, nombreEntrada, arregloRadio, valPredeterminado)
    {
    for (var i=0, len=arregloRadio.length; i < len; i++)
    {
    var radio = mD.agregaEntrada("radio", nombreEntrada, arregloRadio[i][0], nombreEntrada + i);
    if (valPredeterminado == arregloRadio[i][0]) radio.setAttribute('checked', true);
    agregaHijo(nodoPadre, radio);
    agregaNodoTexto(nodoPadre, arregloRadio[i][1]);
    }
    }

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you show us the code for mD.agregaEntrada()?
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it works when I create any input element.

    agregaEntrada: function (tipo, nombre, valor, id, tamano, maxTamano, atributos)
    {
    var entrada = xCreateElement('input');

    if (xDef(tipo)) entrada.setAttribute('type', tipo);
    else return entrada;

    if (xDef(nombre)) entrada.setAttribute('name', nombre);
    else return entrada;

    if (xDef(valor)) entrada.setAttribute('value', valor);
    else entrada.setAttribute('value', '');

    if (xDef(id)) entrada.setAttribute('id', id);
    else entrada.setAttribute('id', nombre);

    if (xDef(tamano))
    {
    entrada.setAttribute('size', tamano);
    if (xDef(maxTamano)) entrada.setAttribute('maxlength', maxTamano);
    else entrada.setAttribute('maxlength', tamano);
    }
    if (xDef(atributos) && (typeof atributos == 'object'))
    {
    for (at in atributos)
    {
    entrada.setAttribute(at, atributos[at]);
    }
    }

    return entrada;
    }

  4. #4
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As I thought, but I wanted to be sure.

    There's a bug in IE regarding setting the name attribute on elements created with document.createElement(). These describe the solution:
    Death to bad DOM Implementations (Anthony Lieuallen's version of the function)
    Setting the "name" attribute in Internet Explorer
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    38
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just one more thing. Does this happen for all elements created by document.createElement()?. Does it happen only for the name attribute?

  6. #6
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most elements don't have a name attribute.

    It's a bug in how IE handles name attributes. As far as I know IE doesn't have this issue with any other attributes.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •