473,386 Members | 1,706 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Element ADDCATEGORY is undefined in FORM.

addcategory.cfml
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>AddCategory</title>
  6. </head>
  7. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  8.     <script type="text/javascript">
  9.         $(document).ready(function() {
  10.             $('#addCategory').click(function() {
  11.                 var addcategory = $('#category').val();
  12.                 alert('data has been stored to database');
  13.                 $.ajax({
  14.                     type: "POST",
  15.  
  16.                     url: 'addcategory.cfc',
  17.  
  18.                     data: {category: addcategory},
  19.  
  20.                     success: function(data) {
  21.                         alert('data has been stored to database');
  22.                     }
  23.                 });
  24.             });
  25.         });
  26.     </script>
  27. </head>
  28. <body>
  29. <form name="category" id="category" method="post" action="addcategory.cfml">
  30. <tr>
  31.     <td>
  32.          Add Category:
  33.     </td>
  34.  <input type ="text" placeholder ="AddCategory"  name="addcategory" id="addcategory" value="">
  35.  <input type="submit" value="Insert" id="addCategory" />
  36. </tr>
  37.  
  38. <cfquery name="category" datasource="myapp">
  39.             INSERT INTO category(categoryname) VALUES ('#Form.addcategory#')
  40. </cfquery>
  41.  
  42. </body>
  43. <script>
  44.  
  45. </body>
  46. </html>
  47.  
  48.  

addcategory.cfc
Expand|Select|Wrap|Line Numbers
  1. <cfcomponent output="false">
  2.  
  3.     <cffunction name="insertcategory" access="remote" returntype="struct">
  4.         <cfargument name="page" type="numeric" required="yes">
  5.         <cfargument name="pageSize" type="numeric" required="yes">
  6.         <cfset var category=queryNew("")>
  7.  
  8.  
  9.          <cfquery name="category" datasource="myapp">
  10.             INSERT INTO category(categoryname) VALUES ('#Form.addcategory#')
  11.             </cfquery>
  12.             <cfoutput> #inserted# </cfoutput>
  13.  
  14.          <cfreturn QueryConvertForGrid(local.category,
  15.                             ARGUMENTS.page,
  16.                             ARGUMENTS.pageSize)>
  17.     </cffunction>
  18. </cfcomponent>
  19.  
  20.  



I have been trying to insert values into sql table using ajax,jquery and cfml. Though the values are been inserted its throwing an error before insertion.
looking for the solution, Thanks in advance...
Mar 21 '19 #1
0 5826

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: lawrence | last post by:
I can't get this page to show in Internet Explorer, so I assume the error is quite grave. I'm using a PHP script to write the RSS file. In Netscape the page shows up as plain text. "Item" is...
4
by: Timo Nentwig | last post by:
Hi! I'm new to XML schemas; can somebody explain why bar is undefined? <xs:element name="bar"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="id"...
2
by: Michael Hill | last post by:
I have this large form with over 150 elements. I need to do some formatting of the data in some of the fields. I do this based on the name of the fields, i.e the field names would be cost1,cost2,...
4
by: George Hester | last post by:
I have a form that has 4 <INPUT> elements in it each with a unique id. The page loads with the <INPUT> id = 1 with focus. If a tab is done immediately without entering anything in this INPUT text...
4
by: Stuart Perryman | last post by:
Hi, I have the following code which works just fine in IE6 but not in Firefox. It is an extract of several table rows each with an individual form. It is generated by php. <form...
6
by: Luke Dalessandro | last post by:
I'm not sure if this is the correct forum for platform specific (Mozilla/Firefox) javascript problems, so just shout and point me to the correct newsgroup if I'm being bad. Here's the deal... ...
4
by: Pasquale | last post by:
I am using the JS and HTML code below to check that required fields are completed for attributes of a product. The first attribute is a select menu and the second is a radio set. My JS goes through...
6
by: ashok.dhananjeyan | last post by:
Hi, Actually , I wrote one javascript to retrieve the name of the form in one particular page. what i did in this page is, <script> function checkbutton() {
1
by: Louis | last post by:
I am building a JS library (to be used in an HTML page, of course) to get and process some data via Google Maps API. The whole result is stored in a single JS object. Then I want to upload them to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.