By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

Alert Box Line Breaks?

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
'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

P: n/a
'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

P: n/a
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.