Solved

llop through characters in textbox

Posted on 2014-10-17
3
60 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

707 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

17 Experts available now in Live!

Get 1:1 Help Now