Solved

CF call function onClick event

Posted on 2010-08-16
3
2,426 Views
Last Modified: 2013-12-24
Hi Experts,
After click on the button, nothing happens, only a sign on the bottom left corner of the page indicating an error on the page and saying Object expected.
Here is a simple code:

<cffunction name="updSchool" >
      <cfargument name="schName" type="string" required="yes">
       <cfquery name="NewSchool" datasource="#datasource#">
              INSERT INTO SCHOOLS (NAME)
            VALUES     ('#schName#')
          </cfquery>

</cffunction>

<cfform name="New">
        Name: <cfinput name="schname" type="text" value="" id="schname"><br>
      <cfinput type="button" value="Add Name" onclick="updSchool('schname';)" name="add"><br>
</cfform>
What am i missing? Please help.
Thank you.
0
Comment
Question by:kqureshi321
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 250 total points
ID: 33449955
The onClick is on browser side and the cffunction is on server side.
You can call server functions only by AJAX.

Check better this:

     <cffunction name="updSchool" >
      <cfargument name="schName" type="string" required="yes">
       <cfquery name="NewSchool" datasource="#datasource#">
              INSERT INTO SCHOOLS (NAME)
            VALUES     ('#schName#')
       </cfquery>
     </cffunction>

<cfform name="New">
        Name: <cfinput name="schname" type="text" value="" id="schname">
      <cfinput type="submit" value="Add Name" name="add"><br>
</cfform>

<cfif isDefined("FORM.add") >
  <cfoutput>
    Upadated: #updSchool(FORM.schname)#
  </cfoutput>
</cfif>

0
 
LVL 63

Expert Comment

by:Zvonko
ID: 33449966
But beside that you will have a long way to make your funaction working: you do not return a result and you name you column Name. That is not the best choice.

0
 

Author Comment

by:kqureshi321
ID: 33469542
thank you for the response.
I tried a function with a returning result and the name of the column not Name, i just put it there for example.
I want to try to use a SP instead of function.
Thanks anyway. I really appreciate it.
0

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question