Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically populated select box overlapped by neighboring div element in IE 7
    primarykey
    data
    text
    <p>I have some legacy JavaScript code that dynamically populates a Select Box. In Firefox, it looks fine. In IE7, the layout is wrong (see below). If I re-size the window, it re-renders the select box properly.</p> <p>Here is a screenshot of what it looks like before re-sizing the browser window.</p> <p><img src="https://i.stack.imgur.com/oDlPf.jpg" alt="IE7 SUCKS"></p> <p>Here is the code complete source code:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt; Test &lt;/title&gt; &lt;/head&gt; &lt;script type="text/javascript"&gt; &lt;!-- var MyOptions = { "A" : "Option 1 (A)", "B" : "Option 2 (B)", "C" : "Option 3 (C)", "D" : "Option 4 (D)" } var MyForm = { loadSelectBox : function () { dropDown=document.getElementById("my_select_box"); while(dropDown.hasChildNodes()) { dropDown.removeChild(dropDown.lastChild); } var firstOption = document.createElement('option'); firstOption.value = ''; firstOption.innerHTML = 'select a filter'; dropDown.appendChild(firstOption); for (var key in MyOptions) { var option = document.createElement('option'); option.value = key; option.innerHTML = MyOptions[key]; dropDown.appendChild(option); } } } function init() { MyForm.loadSelectBox(); } //--&gt; &lt;/script&gt; &lt;body onload="init();"&gt; &lt;div style="margin:0px 10px 0px 10px; width:98%"&gt; &lt;div style="float:left;"&gt; &lt;select id="my_select_box"&gt; &lt;!-- options go here --&gt; &lt;/select&gt; &lt;/div&gt; &lt;div style="float:left;margin-left:25px;"&gt; &lt;input type="checkbox" id="is-foo" style="visibility:visible;"&gt; &lt;label for="is-foo" style="visibility:visible;"&gt;Some label&lt;/label&gt; &lt;input type="button" value="Submit"&gt; &lt;/div&gt; &lt;/div&gt; &lt;br class="clear"/&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>What could I do to make this layout properly in IE7? I need the select box to populate dynamically (this is a dumbed-down version of the code; the actual application is obtaining the values from a web service).</p> <p>I tried intializing the select box with a long value (which the JavaScript will discard), i.e. </p> <pre><code>&lt;select id="my_select_box"&gt; &lt;option name=""&gt;Really long value that will be removed but is here for padding.&lt;/option&gt; &lt;/select&gt; </code></pre> <p>However, this still doesn't look right and feels like a hack. Is there some css that will make the two <code>&lt;div&gt;</code> elements layout nicely?</p>
    singulars
    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