469,957 Members | 2,628 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,957 developers. It's quick & easy.

Alert Box Line Breaks?

Okay, I haven't studied javascript at all and now it's starting to bite
me because I suddenly find myself needing to use some in my php/mysql
web database.

What is the syntax for producing line breaks within the message argument
of an alert box?

I would have thought it would be:

alert("Please correct the following fields:"\n;"Field 1"\n;"Field 2"\n;);

etc.

Can someone please provide a generic example? I will of course continue
googling, etc.

Jul 23 '05 #1
3 33230
'bonehead wrote:
Okay, I haven't studied javascript at all and now it's starting to bite
me because I suddenly find myself needing to use some in my php/mysql
web database.

What is the syntax for producing line breaks within the message argument
of an alert box?

I would have thought it would be:

alert("Please correct the following fields:"\n;"Field 1"\n;"Field 2"\n;);


alert("Please correct the following fields:\nField 1\nField 2\n");

Put the \n inside the quotes, not outside.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
Jul 23 '05 #2
'bonehead wrote:
alert("Please correct the following fields:"\n;"Field 1"\n;"Field 2"\n;);


alert("Please correct the following fields:\nField 1nField 2\n");

Just as it works in many other languages.

Regards,
Svend
Jul 23 '05 #3
In article <40**************@here.org>, 'bonehead says...
Okay, I haven't studied javascript at all and now it's starting to bite
me because I suddenly find myself needing to use some in my php/mysql
web database.

What is the syntax for producing line breaks within the message argument
of an alert box?

I would have thought it would be:

alert("Please correct the following fields:"\n;"Field 1"\n;"Field 2"\n;);


Close. Why did you think putting the \n; outside the quotes would work?

alert("Please correct the following fields:\nField 1\nField 2\n");

--
Hywel I do not eat quiche
http://kibo.org.uk/
http://kibo.org.uk/mfaq.php
Jul 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Bill | last post: by
2 posts views Thread by Mike | last post: by
5 posts views Thread by joelbyrd | last post: by
2 posts views Thread by caspardh | last post: by
8 posts views Thread by Harris Kosmidis | last post: by
1 post views Thread by =?ISO-8859-1?Q?thib=B4?= | last post: by
reply views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.