Populate textarea based on radio button selection

I’ve figured out how to get contents into a textarea based on a radio button selection.


<script>
text = new Array()
text[0] = Array('Saab','Volvo','BMW'); 
text[1] = 'second list';
function populate(r,f){
t=-1;
for(var i=0;i<f.elements[r].length;i++){
if (f.elements[r][i].checked){
var t=i;
}
}
if(t>-1)
{f.txt.value=text[t]
}
}
</script>
</head>
<body>
<form>
<textarea name="txt" cols="20" rows="4"></textarea>
  <br>
  <br>
 <input type="radio" name="radio" value="0" onClick="populate(this.name,this.form)">
  Default List&nbsp;&nbsp;
 <input type="radio" name="radio" value="1" onClick="populate(this.name,this.form)">
  Another List&nbsp;&nbsp;

</form>

But what I can’t figure out is how to separate the lists line-by-line. For example: presenting the first selection above as

Saab
Volvo
BMW

as opposed to

Saab, Volvo, BMW

I assumed I would have to make an array within as array to accomplish this. Am I on the right track?

I assume you mean a multi-dimensional array? Mind expanding on the thought? I’m trying to vision it in my head, but I don’t see where you’re tryin to go…

Nice, thanks man. I appreciate it :slight_smile:

replace with below portion…


if(t>-1){
    f.txt.value= text[t].toString().replace(/,/gi,"\
");
}