SQL Syntax highlighting in a textbox
<p>In my webpage, i have a textbox and a 'execute' button. User can type a query in the textbox and clicks on execute button, it will produce results. 
I want to do sql syntax highlighting in the textbox as the user types. That is, when user types <code>SELECT abc FROM table</code>, I want to show <code>SELECT</code> and <code>FROM</code> in blue color as he types. (like how it is in toad)</p>

<p>I tried to do like following. </p>

<p>1) Having a onkeyup event of the textbox fired. </p>

<p>2) in javascript, i check if the last typed character is a space. </p>

<p>3) Then take the whole text of the textbox and split them into words (using space as delimiter) </p>

<p>4) Check each word and see if it is a keyword (i have all the keywords in a list). </p>

<p>5) if it is a keyword, i add font tags for that particular word like <code>&lt;FONT COLOR='BLUE'&gt;SELECT&lt;/FONT&gt;</code></p>

<p>So, now my final output would be <code>&lt;FONT COLOR='BLUE'&gt;SELECT&lt;/FONT&gt; * &lt;FONT COLOR='BLUE'&gt;FROM &lt;/FONT&gt; table</code></p>

<p>Problem is i am not able to assign this output to <code>textbox.innerHTML</code>. Javascript throws error.</p>

<p>I suppose, textbox's <code>innerhtml</code> cannot take html tags. Is that true?</p>

<p>Is there an alternative to achieve my objective. (I am trying to do in javascript and i dont want to use any third party stuff)</p>
