ZeroDegrez All American 3897 Posts user info edit post |
Hey Guys, can you please use the provided javascript in the website? I often never insert my bold marks or quote marks before pasting or what have you, the following code will let you insert text at the current position of the cursor in a textbox, for atleast IE and if they don't use IE then it will act like normal if it can't use it.
<script language="javascript"> function InsertAtCaret(textarea, txt) { if (textarea.textRange) { textarea.textRange.text = txt; textarea.textRange.select(); } else textarea.value += txt; } function SaveCaret(textarea) { if( textarea.createTextRange ) textarea.textRange = document.selection.createRange(); }
</script>
Heres how you use it:
<form id="myform" name="myform" method="post" action=""> <textarea id="myfield" name="myfield" ONSELECT="SaveCaret(this);" ONCLICK="SaveCaret(this);" ONKEYUP="SaveCaret(this);"></textarea> <br> <input name="test" type="button" value="test" onClick="javascript: InsertAtCaret(document.myform.myfield, 'Insert This Text');"> </form>
Also, can you allow arguments to be passed into the code brakets, so that a language specification can be made, for perhaps future add-ons like keyword colorizing for some of the major languages. Just kinda a look and feel sorta add on.7/20/2004 12:47:11 AM |