[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

message display

can u tell me how I echo this alert with new line (\n)

echo "<script>alert('Le code de validation que vous avez entré est incorrect\n+
           \n The validation code you have entered is incorrect. Please try again.') </script>";

Thanks
0
usmbay
Asked:
usmbay
  • 4
  • 3
  • 2
1 Solution
 
ygouthamCommented:
when you are using a new line character and other things try to enclose them in a double quote (")

echo "<script>alert(\"Le code de validation que vous avez entré est incorrect\n+
           \n The validation code you have entered is incorrect. Please try again.\") </script>";

that should do the trick.
0
 
usmbayAuthor Commented:
no not working
0
 
ygouthamCommented:
a simple

echo "<pre>";
echo "<script>alert(\"Le code de validation que vous avez entré est incorrect
           The validation code you have entered is incorrect. Please try again.\") </script>";
echo "</pre>";


does that work?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
usmbayAuthor Commented:
no
0
 
ygouthamCommented:
then let me suggest the most idiot proof way

<form>
<input type="button" value="Click Here!"
onClick="alert( 'Le code de validation que vous avez entré est incorrect
           The validation code you have entered is incorrect. Please try again.' )">
</form>


the above gives an box with click here for you to click and get the message... let me know if that is fine.
0
 
ygouthamCommented:
i checked it out. and it works only with a \n character in between as a newline break so add that at the end of the line where you want the break.  you can only break with a \n
0
 
Ali KayahanFull Stack DeveloperCommented:
<html>
<script language="javascript">
alert('Le code de validation que vous avez entré est incorrect\n The validation code you have entered is incorrect. Please try again.')
</script>
</html>

this works fine... Hope writing your JS code in a single line...
0
 
usmbayAuthor Commented:
Yes I know it works in javascript, but not with in PHP code
0
 
Ali KayahanFull Stack DeveloperCommented:
<?php echo "
<html>
<script language=\"javascript\">

alert('Le code de validation que vous avez entré est incorrect'+'\\nThe validation code you have entered is incorrect. Please try again.') ;
</script>
</html>"

 ?>
This works just need double slash before n
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now