CF call function onClick event

Posted on 2010-08-16
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#">
            VALUES     ('#schName#')


<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>
What am i missing? Please help.
Thank you.
Question by:kqureshi321
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 63

Accepted Solution

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#">
            VALUES     ('#schName#')

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

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

LVL 63

Expert Comment

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.


Author Comment

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.

Featured Post

Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Reverse Proxy Server 6 97 Hosting Plan security, reliable, stable 1 82
How to solve ssl error handshake failure alert on IE 1 253
Systems talking to each other 5 147
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…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

730 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