Note that there are some explanatory texts on larger screens.

plurals
  1. POInclude div with an ID twice, possible?
    text
    copied!<p>I want to include a file(menu.php) twice, but inside that file I have a div with an ID. Here is menu.php :</p> <pre><code>&lt;?php for ($b = 1; $b &lt;= 10; $b++) { $width = 220; $width /= $b; ?&gt; &lt;div id="menuH&lt;?php print $b; ?&gt;" style="display: none;"&gt; &lt;?php for ($a = 1; $a &lt;= $b; $a++) { print '&lt;div class="voorbeeld_menuH" style="width: '.($width - 1).'px;" &gt;&lt;b&gt;M&lt;/b&gt;&lt;/div&gt;'; } ?&gt; &lt;/div&gt; &lt;?php } for ($b = 1; $b &lt;= 10; $b++) { ?&gt; &lt;div id="menuV&lt;?php print $b; ?&gt;" style="display: none;"&gt; &lt;?php for ($a = 1; $a &lt;= $b; $a++) { print '&lt;div class="voorbeeld_menuV" &gt;&lt;b&gt;M&lt;/b&gt;&lt;/div&gt;'; } ?&gt; &lt;/div&gt; &lt;?php } ?&gt; </code></pre> <p>Javascript code :</p> <pre><code>function menu(dropdown) { var myindex_M = dropdown.selectedIndex; var waarde_M = dropdown.options[myindex_M].value; var i = 1; var a = 1; if(waarde_M == " - - - -") { for(i = 1;1 &lt;= 10;i++) { document.getElementById("menuH" + i).style.display = "none"; document.getElementById("menuV" + i).style.display = "none"; } } for(i = 1;i &lt;= 10;i++) { if(waarde_M == "Menu H " + i) { document.getElementById("menuH" + i).style.display = ""; for(a = 1;a &lt;= 10;a++) { if(a == i) { continue; } document.getElementById("menuH" + a).style.display = "none"; } } } } </code></pre> <p>Where I want to include this : </p> <pre><code>&lt;?php include("Menu.php"); for ($b = 1; $b &lt;= 5; $b++) { ?&gt; &lt;div id="content" style="display: none;"&gt; &lt;?php for ($a = 1; $a &lt;= $b; $a++) { print '&lt;div class="voorbeeld_content'.$b.'"&gt;&lt;b&gt;Content&lt;/b&gt;&lt;/div&gt;'; } ?&gt; &lt;/div&gt; &lt;?php } ?&gt; </code></pre> <p>and include here too : </p> <pre><code>&lt;?php include("Menu.php"); for ($b = 1; $b &lt;= 5; $b++) { ?&gt; &lt;div id="header" style="display: none;"&gt; &lt;?php for ($a = 1; $a &lt;= $b; $a++) { print '&lt;div class="vooorbeeld_header.$b.'"&gt;&lt;b&gt;H&lt;/b&gt;&lt;/div&gt;'; } ?&gt; &lt;/div&gt; &lt;?php } ?&gt; </code></pre> <p>The problem is, the javascript code only works on menu.php, and not in the content.php and header.php, because of the ID tag, how can I solve this?</p>
 

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