Solved

llop through characters in textbox

Posted on 2014-10-17
3
63 Views
Last Modified: 2014-12-09
I would like to be able to loop through characters in a textbox and index them, work out their position and when a new line is started (i.e. when the text reaches the edge of the text box and wraps or when the enter key is pressed.)
0
Comment
Question by:Al4ddin2
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40386582
test page : http://jsfiddle.net/gr9sywt0/1/
var str = document.getElementById("TexboxID").value;
for(var i=0;i<str.length;i++) {
   var character =str.charAt(i)
   alert( character  );
}

Open in new window


<input type="text" id="TexboxID" value="hello" />
0
 

Author Comment

by:Al4ddin2
ID: 40386757
Thanks, say the contents of the textbox has some script that inserts the contents of the textbox into these tags [div]{content to check is in here}[/div] how do I then remove these to do the indexing?
0
 

Author Comment

by:Al4ddin2
ID: 40386775
i.e. rich text formatting
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

932 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now