Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay php in divs using javascript
    text
    copied!<p>I am trying to display different divs depending on a selection from a drop down menu.</p> <pre><code> &lt;html&gt; &lt;head&gt; &lt;title&gt;DDlist Div Display&lt;/title&gt; &lt;script type="text/javascript"&gt; function ShowDivArea(info) { var sel = document.getElementById('divArea').getElementsByTagName('div'); for (var i=0; i&lt;sel.length; i++) { sel[i].style.display = 'none'; } if (info == '0') { return; } document.getElementById('divArea'+info).style.display = 'block'; } &lt;/script&gt; &lt;style type="text/css"&gt; .divArea { display:none; height:100px; width:500px; border:1px solid red; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;select id="DDDivList" onchange="ShowDivArea(this.selectedIndex)"&gt; &lt;option value="0" selected&gt; -- Select A Design Service --&lt;/option&gt; &lt;option value="1"&gt; QR Bookmark &lt;/option&gt; &lt;option value="2"&gt; Twitter &lt;/option&gt; &lt;option value="3"&gt; Ning or Tumblr &lt;/option&gt; &lt;option value="4"&gt; Flyers &lt;/option&gt; &lt;option value="5"&gt; Business Card or Brochure&lt;/option&gt; &lt;option value="6"&gt; Album or Mixtape cover&lt;/option&gt; &lt;option value="7"&gt; Other&lt;/option&gt; &lt;/select&gt; &lt;div id="divArea"&gt; &lt;div id="divArea1" class="divArea"&gt; &lt;form action='code.php' method='GET'&gt; &lt;input type='text' name='myname'&gt;&lt;br&gt; &lt;input type='submit' value='Click here'&gt; &lt;/form&gt; &lt;?php $name = $_GET['myname']; if ($name) echo "Hello, $name."; ?&gt; &lt;/div&gt; &lt;div id="divArea2" class="divArea"&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>You get the point from here on. More divs for each drop down option. </p> <p>This is what I don't get: I want to add a different php script to each div. What should code.php be?</p> <p>Thank you.</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