var text = <?php getit(submit); ?>
It seems you are mixing javascript and php.
in your javascript function that you are trying to pass into a value pulled out by javascript and placed in a php function.
php starts when the page is displayed in the browser, and javascript starts when the user clicks the button.
So, moving everything to javascript, I would do something like:
<script type="text/javascript">
function postit()
{
var submit = document.getElementById("post").value;
var newHTML = submit.replace(/\b(\w+):(\w+)\b/,'<span style="color: $1">$2</span>');
document.getElementById("preview").innerHTML = newHTML;
}
</script>
<div id="preview" style="height: 120px; width: 500px; border: 1px solid grey;">Preview box</div>
<p>
<textarea id="post" cols=70 rows=5/>Submit box - test red:hi</textarea>
<p>
<input type="button" onclick="postit();" value="Submit"/>