Note that there are some explanatory texts on larger screens.

plurals
  1. POdocument.getElementById() in IE Not working? Researched but need different solution
    primarykey
    data
    text
    <p>With the code below, I am trying to make a div with displays 5 hidden divs when using the Next button. However, this does not work in IE because on the line:</p> <pre><code>document.getElementById("pic_container" + c).innerHTML += "&lt;tr id='pic_row" + rowNum + "'&gt;&lt;/tr&gt;"; </code></pre> <p>is trying to change the inner html of a table, which I know IE does not like. If anyone can give me an alternate solution to this problem, feel free to let me know. None of the solutions I found online helped me out, with the styling of td's and all that mumbo jumbo.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;style&gt; #container { height:256px; width:517px; overflow:hidden; border:1px solid black; } .pic_container { height:256px; width:418px; margin-left:50px; margin-right:50px; background-color:yellow; position:relative; } .pic_container input { margin-left:47px; } .image { background-color:red; height:100px; width:100px; } .image2 { background-color:blue; height:50px; width:50px; } &lt;/style&gt; &lt;script&gt; var num = 1; function loadDivs(){ var rowNum = 0; var picNum = 1; for(var c = 1; c&lt;= 5; c++){ document.getElementById("container").innerHTML += "&lt;div class='pic_container'&gt;&lt;table id='pic_container" + c + "'&gt;&lt;/table&gt;&lt;/div&gt;"; for(var x = 0; x&lt;4; x++){ document.getElementById("pic_container" + c).innerHTML += "&lt;tr id='pic_row" + rowNum + "'&gt;&lt;/tr&gt;"; if(x == 0){ for(var dimg = 1; dimg &lt;=4; dimg++){ document.getElementById("pic_row" + rowNum).innerHTML += "&lt;td&gt;&lt;div class='image'&gt;&lt;/div&gt;&lt;/td&gt;"; } } else if(x ==1){ for(var dimg = 1; dimg &lt;=4; dimg++){ document.getElementById("pic_row" + rowNum).innerHTML += "&lt;td&gt;&lt;input type='radio' name='imageChooser' value='Pic " + picNum + "'/&gt;&lt;/td&gt;"; picNum++; } } else if(x == 2){ for(var dimg = 5; dimg &lt;=8; dimg++){ document.getElementById("pic_row" + rowNum).innerHTML += "&lt;td&gt;&lt;div class='image'&gt;&lt;/div&gt;&lt;/td&gt;"; } } else{ for(var dimg = 5; dimg &lt;=8; dimg++){ document.getElementById("pic_row" + rowNum).innerHTML += "&lt;td&gt;&lt;input type='radio' name='imageChooser' value='Pic " + picNum + "'/&gt;&lt;/td&gt;"; picNum++; } } rowNum++; } } } function decrement(){ if(num &gt; 1) num--; } function increment(){ if(num &lt; 5) num++; } function getNextId(){ window.location = "#pic_container" + num;} function display(){ var rads = document.getElementsByName("imageChooser"); for(var i = 0; i &lt; rads.length; i++){ if(rads[i].checked){ document.getElementById("disp_div").innerHTML = rads[i].value; } } } &lt;/script&gt; &lt;/head&gt; &lt;body onLoad="loadDivs()"&gt; &lt;div id="container"&gt; &lt;/div&gt; &lt;a href="javascript:increment(); javascript:getNextId();"&gt;Next&lt;/a&gt; &lt;a href="javascript:decrement(); javascript:getNextId();"&gt;Back&lt;/a&gt; &lt;a href="javascript:display();"&gt;Select&lt;/a&gt; &lt;div id="disp_div"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload