Add paragraph breaks in textarea

T

ThunStorm

I have a script that is working but I can't figure out how to add
paragraph breaks into the textarea. Can anyone help me? If you run the
script, the problem will be easier to understand. If possible too, can
you let me know how to run two instances of the drop down box using the
same array.

<script language="JavaScript">

var teams=new Array()

teams[0]="Karen L. <br><br> Marlene T. <br><br> Joyce A. <br><br>
Mickey Z.";
teams[1]="Joan T. <br><br> June G. <br><br> Alice G. <br><br> Sandy
B.";
teams[2]="Mary B. <br><br> Amy S. <br><br> Carol C. <br><br> Dee V.";
teams[3]="Bev W. <br><br> Fran D. <br><br> Barb F. <br><br> Gerry B.";
teams[4]="Blind <br><br> Lynda F. <br><br> Gail J. <br><br> Val B.";
teams[5]="Helen N. <br><br> Sandy S. <br><br> Pat D. <br><br> Blind";
teams[6]="Dora F. <br><br> Yo P. <br><br> Minnie C. <br><br> Blind";
teams[7]="<br>You Must Bowl NO <br> LESS THAN ( <INPUT TYPE=text
NAME=PPG SIZE=2 MAXLENGTH=3> ) To <br> Take A Point Per Game!!!";
teams[8]="Please select a team!"

function changecontent(which){
document.ddmessage.contentbox.value=teams[which.selectedIndex]
}

document.ddmessage.contentbox.value=teams[document.ddmessage.selectbox.selectedIndex]
</script>
</head>
<body>


<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><form name="ddmessage"><table border="1"
width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><select name="selectbox" size="1"
onChange="changecontent(this)">
<OPTION>Select Team</option>
<OPTION>Alley Cats </option>
<OPTION>Blind</option>
<OPTION>Dreamers</option>
<OPTION>Lucky Strikes </option>
<OPTION>Morn D. Lites </option>
<OPTION>Pin Pals</option>
<OPTION>Pin Ups</option>
<OPTION>Ups + Downs</option>
</SELECT> <br>
</td>
</tr>
<tr>
<td width="100%"><textarea rows="8" name="contentbox"
cols="35" wrap="virtual"></textarea><br>
</td>
</tr>
</table>
</form>
 
R

RobG

ThunStorm said:
I have a script that is working but I can't figure out how to add
paragraph breaks into the textarea. Can anyone help me? If you run the
script, the problem will be easier to understand. If possible too, can
you let me know how to run two instances of the drop down box using the
same array.

Add another select element just like the first.

<script language="JavaScript">

The language attribute is deprecated, type is required.

var teams=new Array()

teams[0]="Karen L. <br><br> Marlene T. <br><br> Joyce A. <br><br>
Mickey Z.";

When posting code, manually wrap it at about 70 characters to allow for
a couple of quotes without auto-wrapping introducing errors.

textareas contain plain text, HTML in them will be displayed as plain
teams[1]="Joan T. <br><br> June G. <br><br> Alice G. <br><br> Sandy
B.";
teams[2]="Mary B. <br><br> Amy S. <br><br> Carol C. <br><br> Dee V.";
teams[3]="Bev W. <br><br> Fran D. <br><br> Barb F. <br><br> Gerry B.";
teams[4]="Blind <br><br> Lynda F. <br><br> Gail J. <br><br> Val B.";
teams[5]="Helen N. <br><br> Sandy S. <br><br> Pat D. <br><br> Blind";
teams[6]="Dora F. <br><br> Yo P. <br><br> Minnie C. <br><br> Blind";
teams[7]="<br>You Must Bowl NO <br> LESS THAN ( <INPUT TYPE=text
NAME=PPG SIZE=2 MAXLENGTH=3> ) To <br> Take A Point Per Game!!!";

That isn't going to work even if you fix the wrapping issue.

teams[8]="Please select a team!"

function changecontent(which){
document.ddmessage.contentbox.value=teams[which.selectedIndex]


You could use your 'which' reference to make that a bit shorter:

which.form.contentbox.value=teams[which.selectedIndex];


'which' is a property of the event object in Gecko-based browsers
inherited from old Netscape, you may want to use a different name.
Since it's a reference to a select element, why not 'sel' or similar?

}

document.ddmessage.contentbox.value=teams[document.ddmessage.selectbox.selectedIndex]

You can't get references to document objects that haven't been created
yet, run it from the load event (wrapped for posting):

window.onload = function(){
document.ddmessage.contentbox.value =
teams[document.ddmessage.selectbox.selectedIndex];
}


You should ensure that one option has a selected attribute - user agent
behaviour if no option has a selected attribute is undefined, they may
not all decide to make the same option selected by default.
 
D

Dr John Stockton

JRS: In article <[email protected]>
, dated Wed, 8 Mar 2006 17:10:53 remote, seen in
news:comp.lang.javascript said:
I have a script that is working but I can't figure out how to add
paragraph breaks into the textarea. Can anyone help me?

F.Code.value = "aa\n\nbb"

And \t may be useful too.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top