Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You're using <code>[0]</code> on <code>this</code> in your First-Name textbox, but it should be on the actual value instead:</p> <pre><code>onChange="document.getElementById('concat').value=this.value[0];" </code></pre> <p>Alternatively, you could be explicit and use <code>.substring()</code> to get the first character:</p> <pre><code>onChange="document.getElementById('concat').value=this.value.substring(0, 1);" </code></pre> <p>This will get the first character of the input. Though a bit longer to write/read, it will convey your exact purpose.</p> <p><em>Note:</em> If your input is empty, you will get an <code>undefined</code> value inserted into your <code>concat</code> textbox when you use <code>this.value[0]</code> as, well, there is no <code>[0]</code>. Using <code>.substring(0, 1)</code> will give no such text (if it's a concern).</p> <p>Additionally, your second text-box for Last-Name has two typos (based on your sample code) in that it doesn't contain the <code>onchange=</code> attribute <em>and</em> it uses an id <code>txt</code> instead of <code>concat</code>. Also, it doesn't attempt to take a substring of the first-name textbox.</p> <p>Try updating your full block of code to the following:</p> <pre><code>&lt;p&gt;Name&lt;/p&gt; &lt;input type="text" id="name" onchange="document.getElementById('concat').value=this.value.substring(0, 1);" /&gt; &lt;p&gt;Last name&lt;/p&gt; &lt;input type="text" id="last_name" onchange="document.getElementById('concat').value=document.getElementById('name').value.substring(0, 1) + this.value;"/&gt; &lt;p&gt;Concat&lt;/p&gt; &lt;input type="text" id="concat" /&gt; </code></pre>
    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. This table or related slice is empty.
    1. This table or related slice is empty.
    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