You are here: Re: Advanced HTML DOM Issue « HTML « IT news, forums, messages
Re: Advanced HTML DOM Issue

Posted by Whit on 09/28/14 11:57

Exactly what I needed. Thank you very much for your help.

-- 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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация