<textarea id="table">Cell 1 | Cell 2 Cell 3 | Cell 4</textarea> <input type="button" onclick="build_table(document.getElementById('table'))" value="Build" /> <script></script>