Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Move cursor to the end of the text field

Posted on 2006-07-06
8
Medium Priority
?
1,988 Views
Last Modified: 2012-06-21
Is there a way that I can move the cursor to the end of the text in a textbox instead of the default of overwriting what is already in there?
0
Comment
Question by:DuNuNuBatman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 17050628


There is no method to direct move the cursor.
The overwrite method is only a side effect to the cursor.



0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 1400 total points
ID: 17050783
IE: http://www.faqts.com/knowledge_base/view.phtml/aid/17749

However there is an exploit in unpatched IE's that will block this code in some firewalls
0
 
LVL 2

Expert Comment

by:yyyannag
ID: 17051231
var range = document.all["message_content"].createTextRange();
range.collapse(true);
range.select();

worked for me :)
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 12

Assisted Solution

by:Preece
Preece earned 600 total points
ID: 17051458
Try this, it works with a textarea and a textbox and has been tested with IE only:

<script language="JavaScript" type="text/javascript">
<!--
function moveToEnd (el) {
 if (el.createTextRange) {
   var v = el.value;
   var r = el.createTextRange();
   r.moveStart('character', v.length);
   r.select();
 }
}

//-->
</script>


response.write "<br><br><input type=textbox size=20 onFocus='javascript:moveToEnd(this)'>"
response.write "<br><br><textarea cols=20 rows=20 onFocus='javascript:moveToEnd(this)'>test</textarea>"


Preece
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 17054019
Preece - could you not copy and paste the code from my suggestion and call it your own?
0
 
LVL 12

Expert Comment

by:Preece
ID: 17054991
Hey, mplungjan.  I found that solution in another previously asked question here on EE.  The other question was actually enquiring about this cursor issue with regards to a textarea.  I then tested it with both a textarea and a textbox, it worked, then I posted my code.  

Sorry, didn't look at your link.

Sincerely,
Preece
0
 
LVL 12

Expert Comment

by:Preece
ID: 17055018
Here is that paq that I was referring to:

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20702525.html

Cheers,
Preece
0
 

Author Comment

by:DuNuNuBatman
ID: 17108313
awesome guys, thanks for the help
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question