|
Posted by Whit on 11/26/27 11:57
I notice you are managing scrollTop attribute of a textarea. Is there
any way to manage a scrollLeft attribute of regular text input field? I
can't seem to find such an attribute.
var myNodeScrollLeft=myNode.scrollLeft;
var myCaret=getCaret(myNode);
myNode.value=myNode.value.toTitleCase();
if (myNode.scrollLeft!=myNodeScrollLeft) {
myNode.scrollLeft=myNodeScrollLeft;
}
Like that, but obviously not, because myNode.scrollLeft ain't workin'.
Thanks again,
-- whit
BootNic wrote:
> > Whit <whitnelson@gmail.com> wrote:
> > news: 1157434094.272693.64600@p79g2000cwp.googlegroups.com
> > I'm sorry, I wasn't explicit enough, I meant to say capitalize the
> > first letter of each word. Meaning I have to read the whole string,
> > cap the first letter of words and un-cap the rest, then re-assign it
> > ... I have already written the function for this. But re-assignment
> > of the whole string causes the field to forget where the cursor is ...
>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
>
> <html>
> <head>
>
> <script type="text/javascript">
> var myTicker,myStore,myNo;
> function Tcase(myNode)
> {
> if(!myNode)
> {
> window.clearInterval(myTicker);
> myTicker=myStore=myNo=null;
> return;
> }
> else if(myStore==myNode.value)
> {
> return;
> }
> else if(!myTicker)
> {
> myNo=myNode;
> window.clearInterval(myTicker);
> myTicker=window.setInterval("Tcase(myNo)",250);
> }
> var myNodeScrollTop=myNode.scrollTop;
> var myCaret=getCaret(myNode);
> myNode.value=myNode.value.toTitleCase();
> if(myNode.scrollTop!=myNodeScrollTop)
> {
> myNode.scrollTop=myNodeScrollTop;
> }
> setCaret(myNode,myCaret,myCaret);
> myNode.focus();
> }
>
> function getCaret(myNode)
> {
> if(typeof myNode.selectionStart != "undefined")
> {
> return myNode.selectionStart;
> }
> else if (document.selection)
> {
> myNode.focus ();
> var Sel = document.selection.createRange ();
> Sel.moveStart ('character', -myNode.value.length);
> return Sel.text.length;
> }
> }
>
> function setCaret (myNode, start, end) {
> if (myNode.createTextRange) {
> var range = myNode.createTextRange();
> range.collapse(true);
> range.moveStart("character", start);
> range.moveEnd("character", 0);
> range.select();
> }
> else if (myNode.setSelectionRange) {
> myNode.focus();
> myNode.setSelectionRange( start, end);
> }
> }
>
> String.prototype.toTitleCase = function()
> {
> myStore=outstr=this.toLowerCase().replace(/\b([a-z])/g,
> function($0){return $0.toUpperCase();});
> return outstr;
> };
> </script>
>
> <title>Title Case</title>
> <meta http-equiv="content-type" content=
> "text/html; charset=windows-1252">
> </head>
>
> <body>
> <div style="text-align:center;">
> <textarea rows="25" cols="40" onfocus="Tcase(this)" onblur=
> "Tcase()">
> </textarea>
> </div>
> </body>
> </html>
>
> --
> BootNic Tuesday, September 05, 2006 3:04 PM
>
> Good communication is as stimulating as black coffee and just as hard
> to sleep after.
> *Anne Morrow Lindbergh*
Navigation:
[Reply to this message]
|