Ask Experts Questions for FREE Help!
  Advanced
Register  |  Log in  
   Ask    
 Answer  
  Help  

Ask QuestionsprogressAnswer QuestionsprogressBuild ReputationprogressBecome an Expert
 
Free Answers in 3 Easy Steps

Register Now
3 Steps

At Ask Me Help Desk you can ask questions in any topic and have them answered for free by our experts. To ask questions or participate in answering them you must register for a free account. By registering you will be able to:
  • Get free answers from experts in any of our 300+ topics.
  • Accept money for answers that you provide.
  • Communicate privately with other members (PM).
  • See fewer ads.

Home > Computers & Technology > Programming > Scripting > Javascript   »   Textarea cursor position

 
Question Tools Search this Question Display Modes
Question
 
 
#1  
Old Jan 2, 2008, 03:01 AM
benn11's Avatar
benn11
Ultra Member
benn11 is offline
 
Join Date: Apr 2007
Posts: 1,032
benn11 See this member's comment history on his/her Profile page.
Textarea cursor position

I have a textarea in an asp page and I have an attribute to insert * symbol in the textarea upon a click in the textarea. Using "<textarea name="text" onfocus="if(this.value=='') this.value='*';">"

The problem is that the cursor returns to the start position but I want the cursor to remain in the position after the * symbol is automatically inserted. How can this be done?

Reply With Quote
 
     

Answers
 
 
Old Jan 16, 2008, 07:20 AM   #2  
jstrike
Full Member
jstrike is offline
 
Join Date: May 2007
Location: Wisconsin - Go Packers!
Posts: 370
jstrike See this member's comment history on his/her Profile page.
This should work:

Code:
<textarea name="myTextArea" onClick="placeText(this,'*')"></textArea> <script> function placeText(txtArea, txt) { if(txtArea.value!="") return; txtArea.value=txt; //FF will automatically put the cursor at the end so skip this IE specific part... if(navigator.userAgent.toLowerCase().indexOf("msie") != -1) { var range = txtArea.createTextRange(); range.moveStart('character', 1); range.select(); } } </script>
  Reply With Quote
 
     


Question Tools Search this Question
Search this Question:

Advanced Search
Display Modes

 
Similar Sponsors

Similar Questions
Question Asker Topic Answers Last Post
Flashing cursor Stephanie9 Networking 1 Sep 17, 2007 06:20 AM
cursor trouble ponytailbob Other Hardware 1 Aug 16, 2007 07:00 AM
Computer Cursor rugbug1 Computers for Beginners 2 Aug 8, 2007 06:39 AM
How to place a textarea with all functionality Grammarian-Bot Other Computers 0 Jan 28, 2007 09:03 AM
Blink cursor passaic33 Desktops 5 Oct 24, 2006 09:12 AM




Copyright ©2003 - 2007, Ask Me Help Desk.
All times are GMT -8. The time now is 10:50 PM.

Content Relevant URLs by vBSEO 3.0.0 RC6 © 2006, Crawlability, Inc.