Note that there are some explanatory texts on larger screens.

plurals
  1. POOnclick - Multiple JavaScript Queries
    text
    copied!<p>I've read and tried numerous suggestions from Stack Overflow but none worked for me, forcing me to ask in person...</p> <p>Currently I use this code to show and hide some content, the id <code>tb1</code> is the <code>div</code> tag my content is wrapped in.</p> <pre><code>&lt;input type="button" value="Information" onclick="javascript:sizeTbl('block');" /&gt; &lt;a href="javascript:sizeTbl('none');"&gt;(&lt;i&gt;Close&lt;/i&gt;)&lt;/a&gt; </code></pre> <p>The button is "Information" and I've added a clickable link that closes the content, because I can't get the button to register the <code>javascript:sizeTbl('none');"&gt;(&lt;i&gt;Close&lt;/i&gt;)</code> </p> <p>Can someone please tell me how to do this, I've tried simply adding the <code>javascript:sizeTbl('none');"&gt;(&lt;i&gt;Close&lt;/i&gt;)</code> after the first onclick command like so</p> <p><code>onclick="javascript:sizeTbl('block');javascript:sizeTbl('none');"</code> but it doesn't work and I've also tried the below linked fixes but to no avail.</p> <p><a href="https://stackoverflow.com/questions/3910736/onclick-multiple-javascript-functions">How to call multiple JavaScript functions in onclick event?</a></p> <p><a href="https://stackoverflow.com/questions/10544520/two-onclick-actions-one-button">Two onClick actions one button</a></p> <p>In case it's needed here is the main JS that defines <code>tb1</code> etc.. I've also tried adding a new function directly in to that script (as I thought calling <code>tb1</code> outside might cause an issue)</p> <pre><code>function sizeTbl(h) { var tbl = document.getElementById('tbl'); tbl.style.display = h; } function sizeTb2(h) { var tb2 = document.getElementById('tb2'); tb2.style.display = h; } function sizeTb3(h) { var tb3 = document.getElementById('tb3'); tb3.style.display = h; } function sizeTb4(h) { var tb4 = document.getElementById('tb4'); tb4.style.display = h; } $('#toggle-view').on('click', function() { var button = $(this); if ( button.hasClass('view-page') ) { ViewPage(); button.removeClass('view-page'); } else { ViewMenu(); button.addClass('view-page'); } }); </code></pre>
 

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