Javascript show example of a chose
<p>I've got a dropdownbox with 10 options, and when you click an option, I want it to show an example of what you choose. The option is how many menu bars/divs you would like, and the example is in <code>&lt;div id="example"&gt;&lt;/div&gt;</code>, my question is, do I have to enter all div's with a loop and enter all width's and height's for every single div? (that would be a VERY large CSS file)</p>

<p>I'm using javascript for which option have been choose. Example :</p>

<pre><code>&lt;script&gt;
function header(dropdown)
{
 var myindex_H = dropdown.selectedIndex;
 var waarde_H = dropdown.options[myindex_H].value;

 if(waarde_H == "Menu H 1")
 {
     document.getElementById("option1").style.display = "";
 }
}
&lt;/script&gt; 
</code></pre>

<p>Remember I'm using a loop, this is just an example of only 1 div</p>

<pre><code>&lt;table&gt;
   &lt;tr&gt;
     &lt;td&gt;
     &lt;form action="index.php" method="POST"&gt;
          &lt;b&gt;Menu : &lt;/b&gt;
          &lt;select name="Menu" onKeyUp="menu(this.form.Menu);"&gt;
          &lt;option&gt; - - - -&lt;/option&gt;
          &lt;?php
               for($a = 1;$a &lt;= 10;$a++) { print '&lt;option&gt;Menu H '.$a.'&lt;/option&gt;'; }
          ?&gt;
          &lt;/select&gt;
     &lt;/form&gt;
     &lt;/td&gt;
     &lt;td&gt;
          &lt;div id="example" &gt;
             //Create div that shows the example
             //I use a PHP loop for this, but I use an example now for only 1 div
             &lt;div id="option1" style="display: none;"&gt;
                  &lt;div class="example-menu-bar1"&gt;
                  &lt;/div&gt;
             &lt;/div&gt;
              //all div's inside here for every option
              //example : option 1 have 1 div
              //          option 2 have 2 divs
              //          .....................
              //          option 10 have 10 divs
          &lt;/div&gt;
     &lt;/td&gt;
  &lt;/tr&gt;
&lt;table&gt;
</code></pre>

<p>Everything works, only my main problem is that in my CSS code, I need to make a class for every option, because every option have diferent width's. So the question is, is there a smarter and faster way for this?</p>

<p>I hope to hear from you soon, thanks for reading :)</p>

<p>Kind regards,</p>

<p>Jeroen</p>
