Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default library functions

    I am just getting started with Coldfusion and am currently using Coldfusion
    MX 6.1.

    I have read that you can store functions in a seperate page and call them
    from within your site.

    To this end I have a field on my Test2.cmf page that reads:

    <input name="txtUsername" type="text"
    onKeyDown="changeDetails('mytestform','hasChangedF lag')" value=
    "<cfoutput>#getRisk.Risk#</cfoutput>"


    and on a seperate page FunctionLibrary.cfm which is on the same site as my
    Test2.cmf page I have:

    <script language="JavaScript">
    function changeDetails(Formname, Fieldname){
    eval("document." + Formname + "." + Fieldname + ".value='1'");
    eval("document." + Formname + ".Submit.disabled=false");
    alert("You are here");

    }
    </script>

    When I try to run it I get an error 'Object Expected' for the line that
    calls the function. If I move the function into Test2.cmf it all works
    fine.

    Is there any special method by which i include a reference to the
    FunctionLibrary.cfm from the Test2.cmf page? Can anyone think of a reason
    why it should not work?

    Many thanks

    Neme


    June Macleod Guest

  2. Similar Questions and Discussions

    1. constructor in dynamicly loaded library containing user defined functions not run when loading from mysql?
      Hi, I've been writing a user defined function with a very expensive initialisation which only needs to run once. I thought it might be possible...
    2. Cannot instantiate .NET Class Library to expose webservice client library
      Now that I have got the mickey mouse .NET interop problem sorted (exposing ..NET library to ASP/VB6), I want to demo the real problem I am having. ...
    3. #10743 [Com]: class functions & PHP core functions inconsistently clash ;)
      ID: 10743 Comment by: destes at ix dot netcom dot com Reported By: jjones at net-conex dot com Status: Open...
    4. ~/Library/ vs ~/System/Library vs /User/Library/
      In article <110720031327074895%justin.c@se.net>, justin <justin.c@se.net> wrote: First off, you're a little bit confused. ~ means your home...
    5. [XFree86] system can't find library ( strange library behaviour )
      Hi Mark, No I hadn't tried ldconfig, but it sorted out the problem, thanks! I'd read a little bit about libraries a while ago, but could not...
  3. #2

    Default Re: library functions

    On your test2.cfm page, do you have anything resembling
    <script language="javascript> src="FunctionLibrary.cfm"> ?

    Originally posted by: Newsgroup User
    I am just getting started with Coldfusion and am currently using Coldfusion
    MX 6.1.

    I have read that you can store functions in a seperate page and call them
    from within your site.

    To this end I have a field on my Test2.cmf page that reads:

    <input name="txtUsername" type="text"
    onKeyDown="changeDetails('mytestform','hasChangedF lag')" value=
    "<cfoutput>#getRisk.Risk#</cfoutput>"


    and on a seperate page FunctionLibrary.cfm which is on the same site as my
    Test2.cmf page I have:

    <script language="JavaScript">
    function changeDetails(Formname, Fieldname){
    eval("document." + Formname + "." + Fieldname + ".value='1'");
    eval("document." + Formname + ".Submit.disabled=false");
    alert("You are here");

    }
    </script>

    When I try to run it I get an error 'Object Expected' for the line that
    calls the function. If I move the function into Test2.cmf it all works
    fine.

    Is there any special method by which i include a reference to the
    FunctionLibrary.cfm from the Test2.cmf page? Can anyone think of a reason
    why it should not work?

    Many thanks

    Neme






    Dan Bracuk Guest

  4. #3

    Default Re: library functions

    I had the language part but not the src part.
    <script language="JavaScript" src="/functionlibrary.cfm">

    I have now added that in but am still getting the same error. Any other
    thoughts?

    June

    "Dan Bracuk" <webforumsuser@macromedia.com> wrote in message
    news:dk7s7c$g26$1@forums.macromedia.com...
    > On your test2.cfm page, do you have anything resembling
    > <script language="javascript> src="FunctionLibrary.cfm"> ?
    >
    > Originally posted by: Newsgroup User
    > I am just getting started with Coldfusion and am currently using
    Coldfusion
    > MX 6.1.
    >
    > I have read that you can store functions in a seperate page and call them
    > from within your site.
    >
    > To this end I have a field on my Test2.cmf page that reads:
    >
    > <input name="txtUsername" type="text"
    > onKeyDown="changeDetails('mytestform','hasChangedF lag')" value=
    > "<cfoutput>#getRisk.Risk#</cfoutput>"
    >
    >
    > and on a seperate page FunctionLibrary.cfm which is on the same site as
    my
    > Test2.cmf page I have:
    >
    > <script language="JavaScript">
    > function changeDetails(Formname, Fieldname){
    > eval("document." + Formname + "." + Fieldname + ".value='1'");
    > eval("document." + Formname + ".Submit.disabled=false");
    > alert("You are here");
    >
    > }
    > </script>
    >
    > When I try to run it I get an error 'Object Expected' for the line that
    > calls the function. If I move the function into Test2.cmf it all works
    > fine.
    >
    > Is there any special method by which i include a reference to the
    > FunctionLibrary.cfm from the Test2.cmf page? Can anyone think of a
    reason
    > why it should not work?
    >
    > Many thanks
    >
    > Neme
    >
    >
    >
    >
    >
    >

    June Macleod Guest

  5. #4

    Default Re: library functions

    Is functionlibrary.cfm in the root directory? If not, why do you have a
    forward slash in front of it?

    Originally posted by: Newsgroup User
    I had the language part but not the src part.
    <script language="JavaScript" src="/functionlibrary.cfm">

    I have now added that in but am still getting the same error. Any other
    thoughts?





    Dan Bracuk Guest

  6. #5

    Default Re: library functions

    My site is at D:\CFusionMX\wwwroot\Riskmax and the functionlibrary.cfm is in
    that folder, as is the Test2.cfm which calls it.

    I have tried setting the src= with and without the slash but the 'Object
    Expected' error continues to appear.




    "Dan Bracuk" <webforumsuser@macromedia.com> wrote in message
    news:dk8032$li0$1@forums.macromedia.com...
    > Is functionlibrary.cfm in the root directory? If not, why do you have a
    > forward slash in front of it?
    >
    > Originally posted by: Newsgroup User
    > I had the language part but not the src part.
    > <script language="JavaScript" src="/functionlibrary.cfm">
    >
    > I have now added that in but am still getting the same error. Any other
    > thoughts?
    >
    >
    >
    >
    >

    June Macleod Guest

  7. #6

    Default Re: library functions

    I have read that you can store functions in a seperate page and call them

    I think you've gotten a bit confused here.

    Your code is using JAvascript functions, what you probably read was refering
    to either UDF (user defined functions) written in ColdFusion or possible CFCs,
    Cold Fusion Components - more likely the first

    Using Javascript in an external file is no difference with CF that it is with
    HTML, ASP etc - the file providing the javascript is included using
    <javascript...> etc in the head of the file to use it. What you'll need to be
    using is code like;

    If it we me, I'd rename functionlibrary.cfm to functionlibrary.js to
    distinguish it from files providing ColdFusion functions as opposed to
    Javascript

    johnab Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139