dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Function definition placement

  1. #1
    Join Date
    Feb 2013
    Location
    Roanoke, VA
    Posts
    10

    Function definition placement

    In an ASP file, if the definition of the function F() is taken out from within <% %> and placed within
    <script>
    </script>
    then the server returns with an error.
    Is there some rule governing function placement?



    <script>
    </script>

    <%
    function F()
    {
    return 7.0;
    }
    var Seven = F();
    Response.write("Seven = " + Seven);
    %>

  2. #2
    Join Date
    Dec 2012
    Location
    NSW Australia
    Posts
    73
    Quote Originally Posted by ROK View Post
    Is there some rule governing function placement?
    there is...

    functions should be declared before the are used...(according to jslint)..

    JS functions that manipulate the html must wait for the html is finished loading before JS can do its stuff...

    as for you error what makes you think that ASP and JavaScript are interchangeable as you have tried to do...

  3. #3
    Join Date
    Feb 2013
    Location
    Roanoke, VA
    Posts
    10
    Thanks for the reply.
    YES on your statements #1 (20 years at C++ taught me that) & #2.

    #3: "ASP and JavaScript are (not) interchangeable": I never thought that they were interchangeable, just similar. In the example that I supplied, the syntax is acceptable in both locations, but a function defined withing <script> </script> is not callable within <% %>. That is the issue.

    I stumble upon this anmomoly when I was using the syntax '... src= "..." ' as an "include" statement within <script> </script>. I have recently seen in the literature the syntax "#include" for ASP code. I'm looking into that now.

    (p.s. If you were to view my profile, you might want to modify you moniker to "GrumpyNotSoOldMan"

  4. #4
    Join Date
    Dec 2012
    Location
    NSW Australia
    Posts
    73
    Talk about shooting the messenger.

    As for your profile I could not care if you where Gates, Hickson or Crockford for that matter.

    Your request showed a snippet of ASP (a server side scripting language) that was being dumped into some HTML script tags supposedly as JavaScript (a client side scripting language) and wondering why there was an error. Then in the same breath mentions they know they are not interchangeable. How bizarre?
    If you are willing to rephrase your request so we do not need to view your profile and be mid readers then some-one will respond appropriately. I look forward to it.

    Kind regards
    grumpyOleMan

  5. #5
    Join Date
    Feb 2013
    Location
    Roanoke, VA
    Posts
    10
    My P.S., as indicated by the accompaning icon, was intended to interject a bit of potential humor relating to our relative ages.
    Your moniker is apropos without modification.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles