Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CF call function onClick event

Posted on 2010-08-16
3
Medium Priority
?
3,093 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:Galina Besselyanova
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Zvonko earned 1000 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:Galina Besselyanova
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

916 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