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

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]);
  }
LVL 2
BILL CarlisleAPEX DeveloperAsked:
Who is Participating?
 
leakim971Connect With a Mentor PluritechnicianCommented:
use : bdlist = bdlist.split(":")
0
 
leakim971Connect With a Mentor PluritechnicianCommented:
bdlist[0] equal 36
bdlist[3] equal 4
0
 
leakim971Connect With a Mentor PluritechnicianCommented:
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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Michel PlungjanIT ExpertCommented:
Wow. 3 comments for this? Where do you get the time Leakim?
0
 
leakim971PluritechnicianCommented:
lol... and it's seems, it's not suffisant : the question is still open...
0
 
BILL CarlisleAPEX DeveloperAuthor Commented:
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
 
leakim971PluritechnicianCommented:
I understand, don't worry about our jokes! Thanks a lot for the points! You're very welcome!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.