473,231 Members | 1,633 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,231 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 5704

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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.