Solved

JS - How do I parse a colon delimited string into an Array?

Posted on 2010-08-25
7
783 Views
Last Modified: 2013-11-08
JS - How do I parse a colon delimited string into an Array?

  var bdlist = '36:24:12:4'; -- this actually comes from database

???????????

  for ( var j=0;j< bdlist.length; j++ ){
      alert(bdlist[j]);
  }
0
Comment
Question by:bcarlis
  • 5
7 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 125 total points
Comment Utility
use : bdlist = bdlist.split(":")
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 125 total points
Comment Utility
bdlist[0] equal 36
bdlist[3] equal 4
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 125 total points
Comment Utility
test page :


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<script language="javascript">
	var bdlist = '36:24:12:4'; // -- this actually comes from database
	bdlist = bdlist.split(":");
	for ( var j=0;j< bdlist.length; j++ ){
		alert(bdlist[j]);
	}
</script>
</body>
</html>

Open in new window

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 75

Expert Comment

by:Michel Plungjan
Comment Utility
Wow. 3 comments for this? Where do you get the time Leakim?
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
lol... and it's seems, it's not suffisant : the question is still open...
0
 
LVL 2

Author Closing Comment

by:bcarlis
Comment Utility
You have to give me time to look at it..
:>) I posted before I left work yesterday!

Thank you, my JS is rusty... I remember now..
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
I understand, don't worry about our jokes! Thanks a lot for the points! You're very welcome!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
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)

743 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

18 Experts available now in Live!

Get 1:1 Help Now