HighDots Forums  

Cursor position in an edit

JavaScript discussion (multi-lingual) JavaScript discussion (alt.comp.lang.javascript)


Discuss Cursor position in an edit in the JavaScript discussion (multi-lingual) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Arg
 
Posts: n/a

Default Cursor position in an edit - 08-12-2005 , 04:16 PM






How would I get and set the position of a cursor in a text edit field?

<script language='javascript'>
function csrPos(editName){
var cp=document.getElementById(editName).??? <--- what goes here?
alert(cp);
}
</script>

<edit onkeyup="csrPos('txtIn');" id=txtIn type=text size=50>

TIA



Reply With Quote
  #2  
Old   
Oscar Monteiro
 
Posts: n/a

Default Re: Cursor position in an edit - 08-20-2005 , 09:36 AM







"Arg" <r_arg (AT) hotmail (DOT) com> escreveu na mensagem
news:js7Le.2995$F_7.2552 (AT) fe06 (DOT) lga...
Quote:
How would I get and set the position of a cursor in a text edit field?

script language='javascript'
function csrPos(editName){
var cp=document.getElementById(editName).??? <--- what goes here?
alert(cp);
}
/script

edit onkeyup="csrPos('txtIn');" id=txtIn type=text size=50

TIA

I Think you ment to give focus on the element type so it can be selected on
top of others , so if the browser supports it it stays like:
document.getElementById('editname').focus();

Hope it helps........




Reply With Quote
  #3  
Old   
Oscar Monteiro
 
Posts: n/a

Default Re: Cursor position in an edit - 08-20-2005 , 09:36 AM




"Arg" <r_arg (AT) hotmail (DOT) com> escreveu na mensagem
news:js7Le.2995$F_7.2552 (AT) fe06 (DOT) lga...
Quote:
How would I get and set the position of a cursor in a text edit field?

script language='javascript'
function csrPos(editName){
var cp=document.getElementById(editName).??? <--- what goes here?
alert(cp);
}
/script

edit onkeyup="csrPos('txtIn');" id=txtIn type=text size=50

TIA

I Think you ment to give focus on the element type so it can be selected on
top of others , so if the browser supports it it stays like:
document.getElementById('editname').focus();

Hope it helps........




Reply With Quote
  #4  
Old   
Arg
 
Posts: n/a

Default Re: Cursor position in an edit - 08-22-2005 , 03:40 PM



That helps, I forgot about setting the focus. The edit in question will
already have text in it and I want to be able to move the cursor to a
specific position in that text and also be able to tell what character in
the text the cursor is at.


"Oscar Monteiro" <offm (AT) hotmail (DOT) com> wrote

Quote:
"Arg" <r_arg (AT) hotmail (DOT) com> escreveu na mensagem
news:js7Le.2995$F_7.2552 (AT) fe06 (DOT) lga...
How would I get and set the position of a cursor in a text edit field?

script language='javascript'
function csrPos(editName){
var cp=document.getElementById(editName).??? <--- what goes here?
alert(cp);
}
/script

edit onkeyup="csrPos('txtIn');" id=txtIn type=text size=50

TIA

I Think you ment to give focus on the element type so it can be selected
on top of others , so if the browser supports it it stays like:
document.getElementById('editname').focus();

Hope it helps........





Reply With Quote
  #5  
Old   
Jasen Betts
 
Posts: n/a

Default Re: Cursor position in an edit - 10-15-2005 , 08:28 AM



Quote:
How would I get and set the position of a cursor in a text edit field?
you have to write your own onclick and onkepress handlers to handle the
editing (not a small task). unless you only want it to work in IE.


Bye.
Jasen


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.