?
Solved

Javascript- bulleted list question

Posted on 2003-02-19
3
Medium Priority
?
854 Views
Last Modified: 2010-05-18
Hi folks.
How can I transform a javascript array:
Array("line 1", "line two", "line three (3)", "line 4 (four)");
into a bulleted list in HTML?

..and to make things just a little more complicated, I'm trying to put the list inside a TEXTAREA of a FORM.
0
Comment
Question by:starfailure
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 200 total points
ID: 7981468
You could do something like this ... but the "bullets" in this case are stars (*)

<SCRIPT language='javascript'>

  var ary = new Array("line 1", "line two", "line three (3)", "line 4 (four)");

  function makelist(theForm)
  {
     for ( var i=0,n=ary.length,str=""; i<n; i++ )
     {
         str += "* " + ary[i] + "\n";
     }

     theForm.theTextArea.value = str;
  }

</script>

<FORM name='myform'>
<TEXTAREA name='theTextArea'></textarea>
<INPUT type='button' name='theButton' value="Make List"
   onclick='makelist(this.form);' />
</form>
0
 
LVL 6

Author Comment

by:starfailure
ID: 7981641
Thanks, knightEknight.
That's actually what I was using, but didn't know if there was a simple way to implement LI.  I'll just see if I can find a symbol to use as a bullet.
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 7988239
how about this one:  &#8729;

    str += "&#8729; " + ary[i] + "\n";

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…
Suggested Courses

801 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