Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When you write </p> <pre><code>document.getElementById('one').onclick=alert("A..!"); </code></pre> <p>you set as <code>onclick</code> handler the the returned value of <code>alert("A..!")</code> : it's <code>undefined</code>. So this can't work.</p> <p>What you need is a function definition : </p> <pre><code>document.getElementById('one').onclick = function() {alert("A..!");}; </code></pre> <p>Alternatively, you could have :</p> <pre><code>function myfunc() { alert("A..!"); } document.getElementById('one').onclick = myfunc; </code></pre> <p>But it's fine to write anonymous function definitions, as it keeps the code in the place where it is used and thus is often cleaner.</p> <p>You also need to have you javascript inside a script element :</p> <pre><code>&lt;script&gt; document.getElementById('one').onclick = function() {alert("A..!");}; document.getElementById('two').onclick = function() {alert("B..!");}; document.getElementById('three').onclick = function() {alert("C..!");}; &lt;/script&gt; </code></pre> <p>Here is a complete, fixed, tested version of your page :</p> <pre><code>&lt;div align="center" id="bodyC"&gt; &lt;table width="800" height="100"&gt;&lt;tr&gt; &lt;td class="bodyCC"&gt; &lt;table id="MYtable" class="MYtable" border="0" width="100%" cellpadding="50"&gt;&lt;tr&gt; &lt;td id="one" class="one" onclick=""&gt;ONE&lt;/td&gt; &lt;td id="two" class="two" onclick=""&gt;TWO&lt;/td&gt; &lt;td id="three" class="three" onclick=""&gt;THREE&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;span onclick="download();"&gt;CLICK HERE&lt;/span&gt; &lt;/div&gt; &lt;script&gt; // this function is called when the "Download" button on the website's menu // is pressed, and is soppused to change the "body" table so when the sells // are clicked an alert will pop. function download() { document.getElementById('one').onclick=function(){alert("A..!");}; document.getElementById('two').onclick=function(){alert("B..!");}; document.getElementById('three').onclick=function(){alert("C..!");}; } &lt;/script&gt;​​​​​​​​​​ </code></pre> <p>(I fixed also the HTML comments, and the missing tr) </p> <p>You can click test it <strong><a href="http://jsfiddle.net/dystroy/c3Bj6/" rel="nofollow">here</a></strong> : click on "CLICK HERE" to activate the ability to click on the three other sections (one, two, three).</p>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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