Copy link to clipboard
Copied
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
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
...Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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>