Alert Box Line Breaks?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • 'bonehead

    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;"Fie ld 1"\n;"Field 2"\n;);

    etc.

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

  • Randy Webb

    #2
    Re: Alert Box Line Breaks?

    'bonehead wrote:[color=blue]
    > 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;"Fie ld 1"\n;"Field 2"\n;);[/color]

    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.javas cript FAQ - http://jibbering.com/faq/

    Comment

    • Svend Tofte

      #3
      Re: Alert Box Line Breaks?

      'bonehead wrote:[color=blue]
      > alert("Please correct the following fields:"\n;"Fie ld 1"\n;"Field 2"\n;);[/color]

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

      Just as it works in many other languages.

      Regards,
      Svend

      Comment

      • Hywel

        #4
        Re: Alert Box Line Breaks?

        In article <409D63D5.30005 02@here.org>, 'bonehead says...[color=blue]
        > 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;"Fie ld 1"\n;"Field 2"\n;);[/color]

        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


        Comment

        Working...