/    Sign up×
Community /Pin to ProfileBookmark

determining position of characters in textarea

Hi there

How would I go about determining each individual text character in a textarea? ?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JJun 19.2005 — Do you mean something like this?

<textarea id="t1">Hello World</textarea>

<script type="text/javascript">

<!--

var my_string = document.getElementById("t1").value

for(i=0;i<my_string.length;i++){

alert(my_string.charAt(i))

}

//-->

</script>
Copy linkTweet thisAlerts:
@JericoauthorJun 20.2005 — that'll get me on the right track!

thanks
Copy linkTweet thisAlerts:
@JericoauthorJun 20.2005 — another question: here's my code:

if (my_string.charAt(i)==""){

document.write("&nbsp&nbsp&nbsp&nbsp")

I'm trying to ask if there's a blank space in the text area, and if there is I want to write 4 blank spaces - this code isn't working, but am I close???
Copy linkTweet thisAlerts:
@Mr_JJun 20.2005 — You are close, try this

[code=php]if(my_string.charAt(i)==" "){
document.write("&nbsp&nbsp&nbsp&nbsp")
}[/code]

Note the space between the quotes
Copy linkTweet thisAlerts:
@JericoauthorJun 20.2005 — awww...THANKS!
×

Success!

Help @Jerico 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.3,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...