/    Sign up×
Community /Pin to ProfileBookmark

track line number at client side

Is it possible to track the current line number and character number of the the textarea and display them in the status bar?Can anyone show me some codes?Thanks

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 27.2004 — <textarea rows="5" cols="10" name="myinput" onkeydown="window.status='characters: '+(myinput.value.length-1)+' lines: '+Math.floor((myinput.value.length-1)/10);"></textarea>
Copy linkTweet thisAlerts:
@azure_ssauthorApr 27.2004 — Thank you very much.

But how about if I want the line # and character position where the current cursor is?Anyway to do that?
Copy linkTweet thisAlerts:
@FangApr 27.2004 — Adapt [URL=http://www.alexking.org/blog/2003/06/02/inserting-at-the-cursor-using-javascript/]this[/URL], or read these from [URL=http://forums.webdeveloper.com/search.php?s=&action=showresults&searchid=231735&sortby=lastpost&sortorder=descending]this forum[/URL]
×

Success!

Help @azure_ss spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...