Expected identifier error on window.confirm, need help

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

    #1

    Expected identifier error on window.confirm, need help

    <script>
    <!--

    function willProceedToPa y() {
    var willPay = window.confirm( 'Vill du g' . String.fromChar Code(229) . '
    till betaling?');
    if (willPay) return true;
    return false;
    }

    //-->
    </script>


    <form name=betalingFo rm method=post action=/membersites/betaling.php
    onSubmit="retur n willProceedToPa y()">

    I can't figure out why I am getting this error. I have a form with a submit
    that upon onSubmit will pop up a confirm window asking "Are you sure" (in
    Norwegian I hope). Where did I go wrong?

    Thanx
    Phil


  • Erwin Moller

    #2
    Re: Expected identifier error on window.confirm, need help

    Phil Powell wrote:
    [color=blue]
    > <script>
    > <!--
    >
    > function willProceedToPa y() {
    > var willPay = window.confirm( 'Vill du g' . String.fromChar Code(229) . '
    > till betaling?');
    > if (willPay) return true;
    > return false;
    > }
    >
    > //-->
    > </script>
    >
    >
    > <form name=betalingFo rm method=post action=/membersites/betaling.php
    > onSubmit="retur n willProceedToPa y()">
    >
    > I can't figure out why I am getting this error. I have a form with a
    > submit that upon onSubmit will pop up a confirm window asking "Are you
    > sure" (in
    > Norwegian I hope). Where did I go wrong?[/color]

    Hi Phil,

    In Javascript use + for string concatination, no .

    try this:
    var willPay = window.confirm( 'Vill du g' + String.fromChar Code(229) + 'till
    betaling?');
    [color=blue]
    >
    > Thanx
    > Phil[/color]

    Welcome. :-)

    Regards,
    Erwin Moller

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Expected identifier error on window.confirm, need help

      "Phil Powell" <soazine@erols. com> writes:
      [color=blue]
      > <script>[/color]

      In HTML 4, the type attribute is required on script tags:
      <script type="text/javascript">
      [color=blue]
      > <!--[/color]

      HTML comments are not necessary in script tags.
      [color=blue]
      >
      > function willProceedToPa y() {
      > var willPay = window.confirm( 'Vill du g' . String.fromChar Code(229) . '
      > till betaling?');[/color]

      String concatenation in Javascript uses the "+" operator, not "." like
      Perl. This is the error.
      [color=blue]
      > if (willPay) return true;
      > return false;[/color]

      These two lines could just be written as
      return willPay;
      [color=blue]
      > <form name=betalingFo rm method=post action=/membersites/betaling.php
      > onSubmit="retur n willProceedToPa y()">[/color]

      The action attribute value must be quoted, since it contains "/"
      characters. I recommend quoting all attribute values.
      [color=blue]
      > I can't figure out why I am getting this error. I have a form with a submit
      > that upon onSubmit will pop up a confirm window asking "Are you sure" (in
      > Norwegian I hope). Where did I go wrong?[/color]

      At the "." :)

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      • Phil Powell

        #4
        Re: Expected identifier error on window.confirm, need help

        I basically had a "blond moment" and forgot about the +. You see, the
        script that contained the Javascript code is written in PHP and its
        concatenation is "." and not "+". Basically, I got my syntax mixed up;
        which I realized much later in the evening or earlier in the morning.

        So thanx but I already got it. Finally. :(

        Phil

        PS: I have used <script> for years w/o fail, I use HTML 4.1





        *** Sent via Developersdex http://www.developersdex.com ***
        Don't just participate in USENET...get rewarded for it!

        Comment

        • Lasse Reichstein Nielsen

          #5
          Re: Expected identifier error on window.confirm, need help

          Phil Powell <soazine@erols. com> writes:
          [color=blue]
          > PS: I have used <script> for years w/o fail, I use HTML 4.1[/color]

          No you don't. You *think* you use HTML 4.01, but a script tag
          with no type attribute is not HTML 4.01, as any validator will
          tell you.

          Browsers are used to people writing incorrect HTML, so they happily
          accept it anyway, but that doesn't make it correct.

          /L 'Pedant? Me? Impossible!'
          --
          Lasse Reichstein Nielsen - lrn@hotpop.com
          Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
          'Faith without judgement merely degrades the spirit divine.'

          Comment

          • Phil Powell

            #6
            Re: Expected identifier error on window.confirm, need help

            Put it to you this way: if it ain't broke, don't fix it.

            Not techie, but it's old practical sense from 'back in the day'

            Phil



            *** Sent via Developersdex http://www.developersdex.com ***
            Don't just participate in USENET...get rewarded for it!

            Comment

            Working...