What happened to my code

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

    What happened to my code

    Dear all,

    I have the following java code:

    <script language="javas cript" type="text/javascript">

    var customearray = new array(400);

    for (var i=0;i<400;i++) {
    customarray[i] = "'" + <%=rs("name") %+ "'";
    }

    </script>

    The broser complians at for (var i=0;i<400;i++) {customarray[i] = "'"
    + <%=rs("name") %+ "'";}

    It saids ";" is needed. What's wrong with my code?

    Thanks.
  • Xu, Qian

    #2
    Re: What happened to my code

    hon123456 wrote:
    Dear all,
    >
    I have the following java code:
    >
    <script language="javas cript" type="text/javascript">
    >
    var customearray = new array(400);
    >
    for (var i=0;i<400;i++) {
    customarray[i] = "'" + <%=rs("name") %+ "'";
    }
    >
    </script>
    >
    The broser complians at for (var i=0;i<400;i++) {customarray[i] = "'"
    + <%=rs("name") %+ "'";}
    >
    It saids ";" is needed. What's wrong with my code?
    >
    Thanks.
    How about change <%=rs("name")%t o <%=rs("name");% >


    --
    Xu, Qian (stanleyxu)

    Comment

    • apatheticagnostic

      #3
      Re: What happened to my code

      On Apr 29, 12:52 am, hon123456 <peterhon...@ya hoo.com.hkwrote :
      Dear all,
      >
      I have the following java code:
      >
      <script language="javas cript" type="text/javascript">
      >
      var customearray = new array(400);
      >
      for (var i=0;i<400;i++) {
      customarray[i] = "'" + <%=rs("name") %+ "'";
      }
      >
      </script>
      >
      The broser complians at for (var i=0;i<400;i++) {customarray[i] = "'"
      + <%=rs("name") %+ "'";}
      >
      It saids ";" is needed. What's wrong with my code?
      >
      Thanks.
      What does <%= rs("name") %expand to? Also, this is getting expanded
      server-side, right?

      Comment

      • hon123456

        #4
        Re: What happened to my code

        On 4$B7n(B29$BF |(B, $B2<8a(B1$B; ~(B52$BJ,(B, apatheticagnost ic <apatheticagnos ...@gmail.com>
        wrote:
        On Apr 29, 12:52 am, hon123456 <peterhon...@ya hoo.com.hkwrote :
        >
        >
        >
        >
        >
        Dear all,
        >
        I have the following java code:
        >
        <script language="javas cript" type="text/javascript">
        >
        var customearray = new array(400);
        >
        for (var i=0;i<400;i++) {
        customarray[i] = "'" + <%=rs("name") %+ "'";
        }
        >
        </script>
        >
        The broser complians at for (var i=0;i<400;i++) {customarray[i] = "'"
        + <%=rs("name") %+ "'";}
        >
        It saids ";" is needed. What's wrong with my code?
        >
        Thanks.
        >
        What does <%= rs("name") %expand to? Also, this is getting expanded
        server-side, right?- $Bp,i6Ho0zMQJ8 ;z(B -
        >
        - $Bp}<(Ho0zMQJ8 ;z(B -
        Yes..It is server side variable . Thanks

        Comment

        • hon123456

          #5
          Re: What happened to my code

          On 4$B7n(B29$BF |(B, $B2<8a(B2$B; ~(B14$BJ,(B, hon123456 <peterhon...@ya hoo.com.hkwrote :
          On 4$B7n(B29$BF |(B, $B2<8a(B1$B; ~(B52$BJ,(B, apatheticagnost ic <apatheticagnos ...@gmail.com>
          wrote:
          >
          >
          >
          >
          >
          On Apr 29, 12:52 am, hon123456 <peterhon...@ya hoo.com.hkwrote :
          >
          Dear all,
          >
          I have the following java code:
          >
          <script language="javas cript" type="text/javascript">
          >
          var customearray = new array(400);
          >
          for (var i=0;i<400;i++) {
          customarray[i] = "'" + <%=rs("name") %+ "'";
          }
          >
          </script>
          >
          The broser complians at for (var i=0;i<400;i++) {customarray[i] = "'"
          + <%=rs("name") %+ "'";}
          >
          It saids ";" is needed. What's wrong with my code?
          >
          Thanks.
          >
          What does <%= rs("name") %expand to? Also, this is getting expanded
          server-side, right?- $Bp,i6Ho0zMQJ8 ;z(B -
          >
          - $Bp}<(Ho0zMQJ8 ;z(B -
          >
          Yes..It is server side variable . Thanks- $Bp,i6Ho0zMQJ8 ;z(B -
          >
          - $Bp}<(Ho0zMQJ8 ;z(B -
          rs("name") is a recordset field for ASP. Thanks

          Comment

          • =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=

            #6
            Re: What happened to my code

            hon123456 escribió:
            I have the following java code:
            >
            <script language="javas cript" type="text/javascript">
            >
            var customearray = new array(400);
            >
            for (var i=0;i<400;i++) {
            customarray[i] = "'" + <%=rs("name") %+ "'";
            }
            I see you don't even know what language the code is in :) The main part
            is JavaScript, not Java. And the <% ... %part is ASP, which is a
            server-side language: it should never reach the browser.



            --
            -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
            -- Mi sitio sobre programación web: http://bits.demogracia.com
            -- Mi web de humor al baño María: http://www.demogracia.com
            --

            Comment

            • Stevo

              #7
              Re: What happened to my code

              hon123456 wrote:
              Dear all,
              I have the following java code:
              You have the following ASP/Javascript code.
              <script language="javas cript" type="text/javascript">
              var customearray = new array(400);
              No such thing as array, you mean Array.
              for (var i=0;i<400;i++) {
              customarray[i] = "'" + <%=rs("name") %+ "'";
              }
              </script>
              You're writing to customarray instead of customearray. One of them is
              spelled wrongly. Plus you're writing the same value 400 times. I'll
              assume this is just because you've abstracted the real problem to a
              simpler postable version.
              The broser complians at for (var i=0;i<400;i++) {customarray[i] = "'"
              + <%=rs("name") %+ "'";}
              It saids ";" is needed. What's wrong with my code?
              Thanks.
              Perhaps "name" is returning something with quotes in it. Try commenting
              that line out and replacing it with customarray[i]="hello". That will
              indicate that there's something wrong with what's being returned from
              "name". It's probably got quotes in it. You could try putting an alert
              in there to show what's being inserted.

              Comment

              • Tom Cole

                #8
                Re: What happened to my code

                On Apr 29, 3:20 am, "Álvaro G. Vicario"
                <alvaroNOSPAMTH A...@demogracia .comwrote:
                hon123456 escribió:
                >
                          I have the following java code:
                >
                <script language="javas cript" type="text/javascript">
                >
                var customearray = new array(400);
                >
                for (var i=0;i<400;i++) {
                   customarray[i] = "'"  + <%=rs("name") %+ "'";
                   }
                >
                I see you don't even know what language the code is in :) The main part
                is JavaScript, not Java. And the <% ... %part is ASP,
                or JSP, it uses the same syntax and has...long before ASP even
                existed.

                which is a
                server-side language: it should never reach the browser.
                >
                --
                --http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
                -- Mi sitio sobre programación web:http://bits.demogracia.com
                -- Mi web de humor al baño María:http://www.demogracia.com
                --

                Comment

                • Laser Lips

                  #9
                  Re: What happened to my code

                  Instead of ...

                  customarray[i] = "'" + <%=rs("name") %+ "'";

                  use ...

                  customarray[i] = "'<%=rs("name") %>'";

                  Graham

                  Comment

                  • Laser Lips

                    #10
                    Re: What happened to my code

                    Or even ...

                    customarray[i] = "<%=rs("name")% >";

                    Comment

                    • Stevo

                      #11
                      Re: What happened to my code

                      Laser Lips wrote:
                      Or even ...
                      customarray[i] = "<%=rs("name")% >";
                      That won't work because of the nested quotes.

                      Comment

                      • Lasse Reichstein Nielsen

                        #12
                        Re: What happened to my code

                        Stevo <no@mail.invali dwrites:
                        Laser Lips wrote:
                        >Or even ...
                        >customarray[i] = "<%=rs("name")% >";
                        >
                        That won't work because of the nested quotes.
                        I'd be surprised if it doesn't work.

                        The quotes outside of "<%" and "%>" are in a completely different
                        scope and should not be considered at all when parsing the server-side
                        code. That, on the other hand, will be replaced by a text that,
                        hopefully, doesn't contain quotes before reaching the browser.

                        /L
                        --
                        Lasse Reichstein Nielsen - lrn@hotpop.com
                        DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
                        'Faith without judgement merely degrades the spirit divine.'

                        Comment

                        • Stevo

                          #13
                          Re: What happened to my code

                          Lasse Reichstein Nielsen wrote:
                          Stevo <no@mail.invali dwrites:
                          >
                          >Laser Lips wrote:
                          >>Or even ...
                          >>customarray[i] = "<%=rs("name")% >";
                          >That won't work because of the nested quotes.
                          I'd be surprised if it doesn't work.
                          The quotes outside of "<%" and "%>" are in a completely different
                          scope and should not be considered at all when parsing the server-side
                          code. That, on the other hand, will be replaced by a text that,
                          hopefully, doesn't contain quotes before reaching the browser.
                          Good point, I'm not a server-side person. What you say makes sense.

                          Comment

                          • Thomas 'PointedEars' Lahn

                            #14
                            Re: What happened to my code

                            Tom Cole wrote:
                            On Apr 29, 3:20 am, "Álvaro G. Vicario"
                            >[...] And the <% ... %part is ASP,
                            >
                            or JSP, it uses the same syntax and has...long before ASP even
                            existed.
                            It could even be PHP, with enabled support for ASP-style tags. Possible,
                            but recommended against for shipping code due to possible incompatibility .


                            PointedEars
                            --
                            Use any version of Microsoft Frontpage to create your site.
                            (This won't prevent people from viewing your source, but no one
                            will want to steal it.)
                            -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

                            Comment

                            Working...