Note that there are some explanatory texts on larger screens.

plurals
  1. POTake input text, print to page and open new window onclick
    text
    copied!<p>What I need help with:</p> <p>My page shall take user input text, then show what was entered on the page (no alert) and open a new window on click if a match is found that would be stored in an array or var.</p> <hr> <p>Here is the line I am having trouble with below:</p> <pre><code> onclick="insert(this.form.name.value),show();"/&gt; </code></pre> <hr> <p>Here is the code thus far:</p> <p> Input </p> <pre><code> var array = new Array(); function insert(val){ array[array.length]=val; } function show() { var string="&lt;b&gt;All Element of the Array :&lt;/b&gt;&lt;br&gt;"; for(i = 0; i &lt; array.length; i++) { string =string+array[i]+"&lt;br&gt;"; } if(array.length &gt; 0) document.getElementById('myDiv').innerHTML = string; } function open_win(){ window.open ,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=200, height=305") } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Input&lt;/h2&gt; &lt;form name="form1"&gt; &lt;table width="407"&gt; &lt;tr&gt; &lt;td width="154" align="right"&gt;&lt;b&gt;Name&lt;/b&gt; &lt;td width="9"&gt;&lt;b&gt;&amp;nbsp;:&lt;/b&gt; &lt;td width="224"&gt; &lt;input type="text" name="name"/&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="154" align="right"&gt; &lt;td width="9"&gt; &lt;td width="224"&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td width="154" align="right"&gt; &lt;td width="9"&gt; &lt;td width="224"&gt; &lt;input type="button" Value="Print Name to page and open new window" onclick="insert(this.form.name.value),show();"/&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;div id="myDiv"&gt;&lt;/div&gt; &lt;/body&gt; </code></pre> <p></p> <p>Thank you for your help,</p> <p>Michael</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