User not logged in - login - register
Home Calendar Books School Tool Photo Gallery Message Boards Users Statistics Advertise Site Info
go to bottom | |
 Message Boards » » Insert at caret Page [1]  
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

Who Am I
Suspended
3976 Posts
user info
edit post

for real

7/20/2004 9:59:54 PM

HaLo
All American
14237 Posts
user info
edit post

ahahahaha, that second suggestion is funny. I agree with the first though

7/20/2004 10:54:40 PM

 Message Boards » Feedback Forum » Insert at caret Page [1]  
go to top | |
Admin Options : move topic | lock topic

© 2024 by The Wolf Web - All Rights Reserved.
The material located at this site is not endorsed, sponsored or provided by or on behalf of North Carolina State University.
Powered by CrazyWeb v2.38 - our disclaimer.