Alert box failure

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

    #1

    Alert box failure

    I am trying to get an alert box with line breaks in it. I want to display a
    couple pieces of information, and want them broken up. I tried using \n to
    get a new line, but kept getting errors in my code. Any suggections?

    Thanks in advance,

    ML

    alert("The combination you have selected: " + \n + "Background Color: " +
    color1 + \n + "Text Color: " + color2)

    Of course color1 and color2 have been declared and defined, so I know there
    isn't an error there. Any suggections would be greatly appreicated.

    Thanks again.


  • William Morris

    #2
    Re: Alert box failure

    The idea is right, but the syntax is wrong. Put the \n character inside the
    quotes as part of the string.

    alert("The combination you have selected: \nBackground Color: " + color1 +
    "\nText Color: " + color2)


    --
    William Morris
    Semster, Seamlyne reProductions
    Visit our website, http://www.seamlyne.com, for the most comfortable
    historically inspired clothing you can buy!


    "micahl0180 " <micahl0180@cox .net> wrote in message
    news:k4zec.16$U 83.15@fed1read0 3...[color=blue]
    > I am trying to get an alert box with line breaks in it. I want to display[/color]
    a[color=blue]
    > couple pieces of information, and want them broken up. I tried using \n[/color]
    to[color=blue]
    > get a new line, but kept getting errors in my code. Any suggections?
    >
    > Thanks in advance,
    >
    > ML
    >[/color]
    [color=blue]
    >
    > Of course color1 and color2 have been declared and defined, so I know[/color]
    there[color=blue]
    > isn't an error there. Any suggections would be greatly appreicated.
    >
    > Thanks again.
    >
    >[/color]


    Comment

    • Matt Kruse

      #3
      Re: Alert box failure

      "micahl0180 " <micahl0180@cox .net> wrote:[color=blue]
      > I am trying to get an alert box with line breaks in it.[/color]

      The \n should go _inside_ the quotes.
      [color=blue]
      > alert("The combination you have selected: " + \n + "Background Color: " +
      > color1 + \n + "Text Color: " + color2)[/color]

      alert("The combination you have selected: \nBackground Color: " + color1 +
      "\nText Color: " + color2)

      --
      Matt Kruse
      Javascript Toolbox: http://www.mattkruse.com/javascript/


      Comment

      • micahl0180

        #4
        Re: Alert box failure

        Thank you both very much, that did the trick :-)


        "micahl0180 " <micahl0180@cox .net> wrote in message
        news:k4zec.16$U 83.15@fed1read0 3...[color=blue]
        > I am trying to get an alert box with line breaks in it. I want to display[/color]
        a[color=blue]
        > couple pieces of information, and want them broken up. I tried using \n[/color]
        to[color=blue]
        > get a new line, but kept getting errors in my code. Any suggections?
        >
        > Thanks in advance,
        >
        > ML
        >
        > alert("The combination you have selected: " + \n + "Background Color: " +
        > color1 + \n + "Text Color: " + color2)
        >
        > Of course color1 and color2 have been declared and defined, so I know[/color]
        there[color=blue]
        > isn't an error there. Any suggections would be greatly appreicated.
        >
        > Thanks again.
        >
        >[/color]


        Comment

        Working...