title: javascript insert test before </table> in textarea
body: <p>I have a textarea for entering an actor and character into a table, with javascript, but have to have buttons to add the <code>'&lt;table class="xxxx"&gt;'</code> and a separate button for the closing <code>&lt;/table&gt;</code>, is there a way to modify the following code to add the new actor as character table row before the closing <code>&lt;/table&gt;</code>, therefore eliminating the need for extra buttons?</p>
  
  <pre><code>function addtxt(input) {
  var obj=document.getElementById(input);
  var actortxt = document.getElementById('actor').value;
  var chartxt = document.getElementById('character').value;
  obj.value+="&lt;tr&gt;&lt;td&gt;"+actortxt+"&lt;/td&gt;&lt;td&gt;as&lt;/td&gt;&lt;td&gt;"+chartxt+"&lt;/td&gt;&lt;/tr&gt;";
  }
  </code></pre>