title: How can I insert text via button click at the cursor in the most recent textbox used?
body: <p>I have a form with multiple text boxes and a set of buttons.  Using the Javascript below, I am able to click a button and insert text into one of the named boxes.</p>
  <p>Is it possible to insert text into the most recent/active textbox when a button is clicked?</p>
  <p>Currently I have this, but it's using the specific ID of a text box, rather than the most recently used/active one;</p>
  <pre><code>   $( 'input[type=button]' ).on('click', function(){
        var cursorPos = $('#my_text_box').prop('selectionStart');
        var v = $('#my_text_box').val();
        var textBefore = v.substring(0,  cursorPos );
        var textAfter  = v.substring( cursorPos, v.length );
        $('#my_text_box').val( textBefore+ $(this).val() +textAfter );
      });
  </code></pre>
  <p>Example on JSFiddle for more clarity;</p>
  <p><a href="http://jsfiddle.net/bd1xf0sj/1/" rel="nofollow noreferrer">http://jsfiddle.net/bd1xf0sj/1/</a></p>
  <p>The idea being that depending upon which text box you're in when the button is clicked, instead of using the ID of a certain textbox. The idea being that the buttons can be clicked and any textbox can be used.</p>