Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>jsFiddle: <a href="http://jsfiddle.net/h3XLP/" rel="nofollow">http://jsfiddle.net/h3XLP/</a></h2> <p>very common to get jQuery answers but it's really not that comprehensive with standalone JavaScript</p> <p>note: add the attribute <code>style="display:none;"</code> to the second table</p> <pre><code>var select = document.getElementsByTagName("select")[0]; select.onchange=function(){ if(select.value=="2"){ document.getElementsByTagName("table")[1].style.display="inline"; }else{ document.getElementsByTagName("table")[1].style.display="none"; } } </code></pre> <p>however you should alternatively use below, as you may have more select and table elements in your document</p> <h2><a href="http://jsfiddle.net/h3XLP/1/" rel="nofollow">http://jsfiddle.net/h3XLP/1/</a></h2> <pre><code>var select = document.getElementById("selectnopuppies"); select.onchange=function(){ if(select.value=="2"){ document.getElementById("secondpuppytable").style.display="inline"; }else{ document.getElementById("secondpuppytable").style.display="none"; } } </code></pre> <hr> <pre><code>&lt;p&gt;Please select number of puppies:&lt;/p&gt; &lt;p&gt; &lt;select id="selectnopuppies"&gt; &lt;option value="1"&gt;1&lt;/option&gt; &lt;option value="2"&gt;2&lt;/option&gt; &lt;/select&gt; &lt;/p&gt; &lt;form id="form1" name="form1" method="POST" action="&lt;%=MM_editAction%&gt;"&gt; &lt;p&gt;Puppy 1:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;table width="330" border="0"&gt; &lt;tr&gt; &lt;td&gt;Name:&lt;/td&gt; &lt;td&gt; &lt;input type="text" name="PuppyName1" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Colour:&lt;/td&gt; &lt;td&gt; &lt;input type="text" name="PuppyColour1" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Sex:&lt;/td&gt; &lt;td&gt; &lt;select name="PuppySex1" id="PuppySex1"&gt; &lt;option value=" "&gt;&lt;/option&gt; &lt;option value="Male"&gt;Male&lt;/option&gt; &lt;option value="Female"&gt;Female&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Microchip/DNA Profile:&lt;/td&gt; &lt;td&gt; &lt;select name="PuppyMicrochip1" id="PuppyMicrochip1"&gt; &lt;option value="No"&gt;No&lt;/option&gt; &lt;option value="Microchip"&gt;Microchip&lt;/option&gt; &lt;option value="DNA Profile"&gt;DNA Profile&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;Microchip/DNA Number:&lt;/p&gt; &lt;/td&gt; &lt;td&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;div id="secondpuppytable" style="display:none;"&gt; &lt;p&gt;Puppy 2:&lt;/p&gt; &lt;table width="330" border="0"&gt; &lt;tr&gt; &lt;td&gt;Name:&lt;/td&gt; &lt;td&gt; &lt;input type="text" name="PuppyName2" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Colour:&lt;/td&gt; &lt;td&gt; &lt;input type="text" name="PuppyColour2" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Sex:&lt;/td&gt; &lt;td&gt; &lt;select name="PuppySex2" id="PuppySex2"&gt; &lt;option value=" "&gt;&lt;/option&gt; &lt;option value="Male"&gt;Male&lt;/option&gt; &lt;option value="Female"&gt;Female&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Microchip/DNA Profile:&lt;/td&gt; &lt;td&gt; &lt;select name="PuppyMicrochip2" id="select2"&gt; &lt;option value="No"&gt;No&lt;/option&gt; &lt;option value="Microchip"&gt;Microchip&lt;/option&gt; &lt;option value="DNA Profile"&gt;DNA Profile&lt;/option&gt; &lt;/select&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;p&gt;Microchip/DNA Number:&lt;/p&gt; &lt;/td&gt; &lt;td&gt; &lt;input name="PuppyMicrochipNum2" type="text" id="PuppyMicrochipNum2" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; </code></pre>
    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.
 

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