Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

NEED HELP WITH BUTTON

New Here ,
May 05, 2010 May 05, 2010

HELLO, I'M NEW TO COLDFUSION.

IS THERE A BUTTON FUNCTION AND CLICK WILL TIGGER A COLDFUSION FUNCTION (NOT JAVASCRIPT FUNCTION)? WHAT I'M TRYING TO DO IS TO CREATE A BUTTON AND WHEN USER CLICK ON IT, IT WOULD CALL COLDFUSION FUNCTION. I NEED TO USE CF TAG AND CAN'T USE JAVASCRIPT FUNCTION. OR IS THERE ANY WAY TO USE CF TAG INSIDE JAVASCRIPT (FROM WHAT I UNDERSTAND IS NOT POSSIBLE)?


EG.

<cfinput name="TEST" type="button" value="TEST" onClick="#TEST()#">

<cffunction name="TEST" returntype="void">

          <cfoutput>
        "this is test"
        </cfoutput>
          </cffunction>
      

I DON'T KNOW IF IT IS POSSIBLE. AS, I SAID I'M NEW TO COLDFUSION. ANY HELP WILL BE GREATLY APPRICIATED.

THANKS

TOPICS
Getting started
7.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 06, 2010 May 06, 2010

OnClick, onChange, and so on are triggers for Javascript, and so happen at the client's browser. They are not available at the Colfusion server.That is also what Ian is saying.

Therefore, the code onClick="#test()#", where the lefthand side is Javascript and the righthand side Coldfusion, will fail to call the function upon clicking. However, the code could still work, because Coldfusion could stll run the function, whether or not the button is clicked.

A useful example is something like

<cffunctio

...
Translate
Valorous Hero ,
May 05, 2010 May 05, 2010

As a new developer to ColdFusion a big lesson you need to learn is that ColdFusion is a server technology and only runs on a server and JavaScript is a client technology that only runs on a client and NEVER will the two meet.

You can not have a client user interface Button trigger a server function without the client making sometype of request (HTTP request 99.37% of the time) to the server.

Why can you not use JavaScript?

What type of user interface experience are you willing to accept to do without JavaScript?

Without JavaScript you are pretty much regulated to haveing the Button sumitt a form to the server as either a get or post request, the server processing the date generating a respone and returning it to the client, which will then refresh the page with the new markup from the server.

You can isloate how much of the user interface is involved with the request-response cycle by doing it inside of a frame, inline being the modern choice.

P.S. Why is your Cap-Lock key stuck?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 06, 2010 May 06, 2010
LATEST

OnClick, onChange, and so on are triggers for Javascript, and so happen at the client's browser. They are not available at the Colfusion server.That is also what Ian is saying.

Therefore, the code onClick="#test()#", where the lefthand side is Javascript and the righthand side Coldfusion, will fail to call the function upon clicking. However, the code could still work, because Coldfusion could stll run the function, whether or not the button is clicked.

A useful example is something like

<cffunction name="TEST" returntype="string" output="false">
    <cfreturn "this is test">
</cffunction>

<cfform>
<cfinput name="TEST" type="text" value="#test()#">
</cfform>

The commonest example of running a Coldfusion function upon the click of a button is the submission of a form.  Here is an  example:

<cffunction name="TEST" returntype="string" output="false">
    <cfreturn "This is test. The time is " & timeformat(now(), "HH:MM:SS")>
</cffunction>

<cfif isDefined("form.test")>
<cfoutput>#test()#</cfoutput><br>
</cfif>

<cfform>
<cfinput name="TEST" type="submit" value="Call test()">
</cfform>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources