Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I updated your JSfiddle to have a working example. <a href="http://jsfiddle.net/LXWKu/7/" rel="nofollow">Link</a></p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;Testing&lt;/title&gt; &lt;script type="text/javascript"&gt; var cursorLocation = 0; function insertValue(buttonClicked) { var input = document.getElementById('input'); input.value = input.value.substring(0, cursorLocation) + buttonClicked.innerHTML + input.value.substring(cursorLocation); cursorLocation += 1; } // Script found here: // http://stackoverflow.com/questions/2897155/get-cursor-position-within-an-text-input-field function doGetCaretPosition(oField) { // Initialize var iCaretPos = 0; // IE Support if (document.selection) { // Set focus on the element oField.focus (); // To get cursor position, get empty selection range var oSel = document.selection.createRange (); // Move selection start to 0 position oSel.moveStart ('character', -oField.value.length); // The caret position is selection length iCaretPos = oSel.text.length; } // Firefox support else if (oField.selectionStart || oField.selectionStart == '0') iCaretPos = oField.selectionStart; // Return results cursorLocation = iCaretPos; } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;input onblur="doGetCaretPosition(this)" type="text" id="input"/&gt; &lt;button onclick="insertValue(this)"&gt;A&lt;/button&gt; &lt;button onclick="insertValue(this)"&gt;B&lt;/button&gt; &lt;button onclick="insertValue(this)"&gt;C&lt;/button&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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