Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript Overlap - How do fix toggled show/hide div
    primarykey
    data
    text
    <p><em>I have a webpage with two buttons on it. One button SHOULD open a div that says 'no dates'. The other SHOULD open a div that says 'available.'</em></p> <p><strong>Button 1 HTML/Script:</strong></p> <pre><code>&lt;script&gt; var toggle = function() { var mydiv = document.getElementById('nodate'); if (mydiv.style.display === 'block' || mydiv.style.display === '') mydiv.style.display = 'none'; else mydiv.style.display = 'block' } &lt;/script&gt; &lt;div id="nodate" style="display:none"&gt;&lt;span class="A"&gt; &lt;input type="image" src="http://www.weebly.com/uploads/1/6/7/6/16768236/custom_themes/307429121386408805/files/close-icon.png?1384992227202" width="42" onclick="toggle();" /&gt;&lt;/span&gt;&lt;b&gt;There are no reservations listed under the date you selected. &lt;/b&gt;Please select another date or ask for assistance.&lt;br&gt;&lt;br&gt;&lt;image src=”http://www.weebly.com/uploads/1/6/7/6/16768236/custom_themes/307429121386408805/files/sorry.jpg?1384992565622” width=”200”/&gt;&lt;/div&gt; &lt;input type="submit" style="background-color: #fff; padding: 4px; border: solid 2px #000; cursor:pointer;" value="Friday November 22nd, 2013" onclick="toggle();" class=”days1”&gt;&lt;/input&gt; &lt;br&gt;&lt;br&gt; </code></pre> <p><strong>Button 2 HTML/Script:</strong></p> <pre><code>&lt;script&gt; var toggle = function() { var mydiv = document.getElementById('nodate2'); if (mydiv.style.display === 'block' || mydiv.style.display === '') mydiv.style.display = 'none'; else mydiv.style.display = 'block' } &lt;/script&gt; &lt;div id="nodate2" style="display:none"&gt;&lt;span class="A"&gt; &lt;input type="image" src="http://www.weebly.com/uploads/1/6/7/6/16768236/custom_themes/307429121386408805/files/close-icon.png?1384992227202" width="42" onclick="toggle();" /&gt;&lt;/span&gt;&lt;b&gt;Cool! We’ve got reservations for the date you selected. &lt;/b&gt;&lt;br&gt;&lt;u&gt;Your name must use a proper format or you will be redirected to this page until a correct format and reserved name are used.&lt;/u&gt;&lt;ul&gt;&lt;li&gt;&amp;bull; Both First &amp;amp; Last&lt;/li&gt;&lt;li&gt;&amp;bull; First &amp;amp; Last name must have first letter capitalized&lt;/li&gt;&lt;li&gt;&amp;bull; Single space between first &amp;amp; last name&lt;/li&gt;&lt;/ul&gt;Ex: Austin Block &lt;br&gt;&lt;br&gt;&lt;image img style="border:2px solid #000" src=”http://www.weebly.com/uploads/1/6/7/6/16768236/custom_themes/307429121386408805/files/reservations2.jpg?1385069953644” width=”200”/&gt;&lt;/div&gt; &lt;input type="submit" style="background-color: #fff; padding: 4px; border: solid 2px #000; cursor:pointer;" value="Saturday November 23rd, 2013" onclick="toggle();" class=”days1”&gt;&lt;/input&gt; </code></pre> <p><em>The problem: When I launch the page, only one of the two hidden divs shows up. Both buttons open the SAME one. So basically, I think I need to separate the two scripts. I cannot do Javscript at all (even though went to a class several times). I tried adding an 'a' to the Javascript function across one button, but it refused to work.</em></p>
    singulars
    1. This table or related slice is empty.
    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