Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript Array Alert
    text
    copied!<p>Im new to Javascript.</p> <p>Im trying to code these four buttons. I'm currently on the second one. I've coded an array. But when I click on the button, it replaces the page. I want to display the array in an alert box.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript"&gt; function SayHello() { alert("Hello World!"); } function DumpCustomers() { var aCustomers=new Array(); aCustomers[0]="Frank Sinatra "; aCustomers[1]="Bob Villa "; aCustomers[2]="Kurt Cobain "; aCustomers[3]="Tom Cruise "; aCustomers[4]="Tim Robbins "; aCustomers[5]="Santa Claus "; aCustomers[6]="Easter Bunny "; aCustomers[7]="Clark Kent "; aCustomers[8]="Marry Poppins "; aCustomers[9]="John Wayne "; document.write(aCustomers[0]); document.write(aCustomers[1]); document.write(aCustomers[2]); document.write(aCustomers[3]); document.write(aCustomers[4]); document.write(aCustomers[5]); document.write(aCustomers[6]); document.write(aCustomers[7]); document.write(aCustomers[8]); document.write(aCustomers[9]); } function DisplayFishCounts() { } function FindJonGalt() { } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form name="Main"&gt; &lt;input type="button" id=1 onclick="SayHello();" value="Say Hi"/&gt; &lt;input type="button" id=1 onclick="DumpCustomers();" value="Dump Customers"/&gt; &lt;input type="button" id=1 onclick="DisplayFishCounts();" value="Display Fish Counts"/&gt; &lt;input type="button" id=1 onclick="FindJonGalt();" value="Where is Jon Galt?"/&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </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