Note that there are some explanatory texts on larger screens.

plurals
  1. POdocument.write to current HTML page
    text
    copied!<p>I am a noob to programming, so I'd appreciate any advice from you more knowledgeable folks out there. I am working on a bit of javascript for a web page and I need the javascript to print to that current HTML page, preferably in the div tag I have set up for that purpose. Here's what I have so far: </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Tardy Reporting&lt;/title&gt; &lt;script src="students.js" type="text/javascript"&gt; &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Scan in Student ID&lt;/h1&gt; &lt;form method="POST" name="idForm" onSubmit="getId(parseInt(document.idForm.studentId.value));"&gt; &lt;input type="text" name="studentId" id="studentId"/&gt; &lt;input type="Submit" name="Submit" /&gt; &lt;/form&gt; &lt;div id="div1"&gt;&lt;/div&gt; &lt;p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and my JS file:</p> <pre><code>var studentNumberArray = [50011234, 50012345, 50013456]; var studentNameArray = ["Mike Simpson", "Greg Pollard", "Jason Vigil"]; var studentLastPeriodArray = ["George Washington", "Darth Vadar", "Obi Wan Kenobi"]; var tardyArray = [0, 0, 0]; function getId(studentId) { for (i = 0; i &lt; studentNumberArray.length; i++){ if(studentId === studentNumberArray[i]){ tardyArray[i] += tardyArray[i] + 1; document.getElementById('div1').innerHTML='test'; } } } </code></pre> <p>Mind you, this is just the basic framework, so it's not nearly done yet, but the thing that is bugging me is that it'll go through the code correctly and print it out, but the result only lasts a fraction of a second on my browsers (chromium and firefox). Any help would be appreciated.</p>
 

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