Permalink
Browse files

Added insertAtCursor() function. So far this function is only used by…

… the

datbase module.
  • Loading branch information...
1 parent 7caf140 commit 760b407069da84c5add6a1dec5dcabd9cd2e39cd vyshane committed Mar 15, 2006
Showing with 22 additions and 0 deletions.
  1. +22 −0 lib/javascript-static.js
View
@@ -210,3 +210,25 @@ function fix_column_width(colName) {
}
}
}
+
+
+/*
+ Insert myValue at current cursor position
+*/
+function insertAtCursor(myField, myValue) {
+ // IE support
+ if (document.selection) {
+ myField.focus();
+ sel = document.selection.createRange();
+ sel.text = myValue;
+ }
+ // Mozilla/Netscape support
+ else if (myField.selectionStart || myField.selectionStart == '0') {
+ var startPos = myField.selectionStart;
+ var endPos = myField.selectionEnd;
+ myField.value = myField.value.substring(0, startPos)
+ + myValue + myField.value.substring(endPos, myField.value.length);
+ } else {
+ myField.value += myValue;
+ }
+}

0 comments on commit 760b407

Please sign in to comment.