473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Add paragraph breaks in textarea

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>

Mar 9 '06 #1
2 2821
ThunStorm wrote:
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.

<script type="text/javascript">


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
text. To get new lines, replace <br> with \n.

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.

</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>


--
Rob
Mar 9 '06 #2
JRS: In article <11**********************@p10g2000cwp.googlegroups .com>
, dated Wed, 8 Mar 2006 17:10:53 remote, seen in
news:comp.lang.javascript, ThunStorm <mo******@hotmail.com> posted :
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.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Mar 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Travis Pupkin | last post by:
Hi, I'm putting together a site to allow someone to add content to a DB through a text area form, and then display it on the web. Pretty basic. The problem I'm having is that they need to add...
3
by: EmmettPower | last post by:
Hi, I am building a small CMS for my son's school. Ideally I want to build the system for them and hand it over so that all updates can be done through web-based forms. So far so good....
7
by: John Angel | last post by:
Hi, I have a pretty wierd situation. I have a javascript function that runs when I submit a page. The onsubmit code does quite a bit - it goes through a big textarea and replaces tabs with...
11
by: Johnny Two Dogs | last post by:
I'm strictly concerned with IE, so cross-browser compatibilty isn't necessary. If you view the code below, I almost get exactly what I'm looking for: - A table of four cells that...
1
by: me | last post by:
Hello, I have a node in my xml that is a block of information. This block has several paragraphs--how can I maintain the paragraph breaks by using <br/> from the source thru a xsl tranformation...
5
by: joelbyrd | last post by:
Didn't know exactly where to post this, but: How do I get line breaks in a textarea? I'm pulling text from a database, and this text definately has line breaks in it, because I replaced all the...
14
by: ghostwalker | last post by:
Hi I have an HTML form with a textarea on it. When submitted (using 'get' not 'post') this forms action php file simply does this to retrieve the values: $message = $_GET; Now it all works...
15
by: Yogi | last post by:
Hi there, I have a quick question. In my html document, I want to make a new paragraph whenever I have a blank line in the html source. Using <p> and </pevery time is kind of cumbersome (I want...
14
by: EnjoyNews | last post by:
Hi I have a little probelm. I tranfer som data from input fields to a div so you can see how a profil will look as you type in your data. I just put this in my input field:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.