Advanced Search

Results 1 to 3 of 3

Thread: Wanted someone to debug this script, it doesn't work with IE.

  1. #1
    Join Date
    Feb 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Wanted someone to debug this script, it doesn't work with IE.

    This is that webpage.
    http://yoshibestiary.servegame.org/b...e=newtopic&f=1

    I've making phpBB MOD that user will can add poll without reload the page many times.

    After clicked the button [ Add Option ] on Internet Explorer, it returns "Unknown Error" or Error #0

                // A function to add poll option.
                function addoptions() {
                    pollids++;
                    currentobj = document.getElementById('postingT').insertRow(document.getElementById('newPollRow').rowIndex);
                    // OKay, this is the HTML of the newly added poll row!
    &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; tmphtml = '<td class="row1"><span class="gen"><b>{L_POLL_OPTION}</b></span></td>'
    &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; tmphtml += '<td class="row2"><span class="genmed"><input type="text" name="poll_option_text[' + pollids + ']" size="50" class="post" maxlength="255" value="" /></span>'
    &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; tmphtml += '<input type="button" onClick="document.getElementById(\'postingT\').deleteRow(document.getElementById(\'tehpolid' + pollids + '\').rowIndex); pollids--; return false;" value="{L_DELETE_OPTION}" class="liteoption" />'
    &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; tmphtml += '</td>';
    &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; currentobj.innerHTML = tmphtml;
    &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; // Since currentobj.id is read-only!
    &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; currentobj.setAttribute('id','tehpolid' + pollids);
    &#0160; &#0160; &#0160; &#0160; &#0160; &#0160; }
    There's an error in that red line.
    Can anyone help me fixing this problem please?
    Thank you,
    DTTVB
    Last edited by mechakoopa; 10-25-2005 at 10:39 AM.

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mechakoopa
    currentobj = document.getElementById('postingT').insertRow(document.getElementById('newPollRow').rowIndex);
    /* ... */
    currentobj.innerHTML = tmphtml;
    The innerHTML property is read-only in IE for most table-related elements, including col, colgroup, table, tbody, tfoot, thead, and tr[1]. It's also read-only for some other elements, too: frameset, html, style, and title.

    Use DOM methods, like insertCell, instead.

    // Since currentobj.id is read-only!
    The id property is only read-only in IE4...

    currentobj.setAttribute('id', 'tehpolid' + pollids);
    ...and using the setAttribute method isn't any different - it's just ignored. Moreover, this method exhibits broken behaviour in IE and is best avoided, anyway.

    Mike

  3. #3
    Join Date
    Feb 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    OK! So the code now would be this

    &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; tmphtml_r1 = '<span class="gen"><b>{L_POLL_OPTION}</b></span>';
    &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; tmphtml_r2 = '<span class="genmed"><input type="text" name="poll_option_text[' + pollids + ']" size="50" class="post" maxlength="255" value="" /></span> ';
    &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; tmphtml_r2 += '<input type="button" onClick="document.getElementById(\'postingT\').deleteRow(document.getElementById(\'tehpolid' + pollids + '\').rowIndex); pollids--; return false;" value="{L_DELETE_OPTION}" class="liteoption" />';

    &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; row2 = currentobj.insertCell(0);
    &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; row2.className = 'row2';
    &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; row2.innerHTML = tmphtml_r2;

    &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; row1 = currentobj.insertCell(0);
    &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; row1.className = 'row1';
    &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; row1.innerHTML = tmphtml_r1;


    I made a new <td> element, and change its class name, and insert HTML code, that's worked, and just know that TR is read-only, thanks!

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
  •