?
Solved

Javascript- bulleted list question

Posted on 2003-02-19
3
Medium Priority
?
855 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
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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 …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
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

615 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