Solved

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

Posted on 2010-08-25
7
784 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
ID: 33526908
use : bdlist = bdlist.split(":")
0
 
LVL 82

Assisted Solution

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

Assisted Solution

by:leakim971
leakim971 earned 125 total points
ID: 33526928
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 75

Expert Comment

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

Expert Comment

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

Author Closing Comment

by:bcarlis
ID: 33531555
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
ID: 33535581
I understand, don't worry about our jokes! Thanks a lot for the points! You're very welcome!
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
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…

786 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