Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiline Alert Box!! Error pls Help 1

Status
Not open for further replies.

Forri

Programmer
Oct 29, 2003
479
MT
Hi All

I need to show a multiline alert box but it keeps on giving me an error. The following is what i'm doing:

Code:
 alert ("Hello \n World");

The browser keeps giving the following error:

Unterminated String Constant

Any ideas pls?

Thanks
Nick
 
There's nothing wrong with that line. Looks like your error must be somewhere else, mate.
 
But if i remove the "\n" it works! obviously it doesn't skip a line!

Nick
 
In that case, what browser are you testing this in?

If you put the following in a page by itself do you get an 'Unterminated String Constant' error?

Code:
<script type="text/javascript">
alert ("Hello\nWorld");
</script>
 
#$@%@^%$@ !! it works!!

yes it does work alone! i'm trying to print it from a PHP script!

Do you have any idea how i can do this!

Thanks
Nick
 
Something like this, probably:

Code:
<?php

echo '<script type="text/javascript">';
echo 'alert("hello\nworld");';
echo '</script>';

?>
 
Oh thanks theboyhope!

forgot about the ' i usually use " !! Cheers!

Star for you!!

Thanks once again
Nick
 
It looks like PHP was literally putting a new line in the alert, like:

alert("Hello
World");

 
Yep - it'll parse the \n if you have it inside double quotes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top