Solved

CF call function onClick event

Posted on 2010-08-16
3
2,766 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
[X]
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
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: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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

636 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