We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now

x

COldFusion form submit

Medium Priority
941 Views
Last Modified: 2013-12-24
I am building the report in coldfusion using table. And i have i column called completion which is the checkbox field. Actually this cell is the form itself. What I need to do is to setup the way so when somebody click on that cell it will update the database without refreshing  the report itself

Please help
<td valign="top" align="center">
							<form name="frm" method="post" action="" id="frm">
								<input type="checkbox" name="chk#Employeeid#" value="#getCapstone.isAccept#" onClick="javascript:chkSubmit ();" <cfif getCapstone.isAccept eq 1>checked</cfif>>
							</form>
							<cfif isDefined("form.chk")>
				
								<cfquery name="qryUpdate" datasource="cfelsunrise">
									Update EDITCapstone set isAccept = <cfif getCapstone.isAccept eq 1><cfqueryparam cfsqltype="cf_sql_integer" value="0"><cfelse><cfqueryparam cfsqltype="cf_sql_integer" value="1"></cfif> where EmpID = #EmployeeID#
								</cfquery>
							</cfif>
						</td>

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Commented:


Use ColdFusion.Ajax.submitForm
<td valign="top" align="center">
       <form name="frm" method="post" action="" id="frm">
        <input type="checkbox" name="chk#Employeeid#" value="#getCapstone.isAccept#" onClick="javascript:chkSubmit ();" <cfif getCapstone.isAccept eq 1>checked</cfif>>
       </form>
       
      </td>

<script>
function chkSubmit(){
ColdFusion.Ajax.submitForm('frm','test.cfm',resultHandler);
}
 function resultHandler(result) ()
{
}
</script>

in test .cfm

put this code
<cfif isDefined("form.chk")>
   
        <cfquery name="qryUpdate" datasource="cfelsunrise">
         Update EDITCapstone set isAccept = <cfif getCapstone.isAccept eq 1><cfqueryparam cfsqltype="cf_sql_integer" value="0"><cfelse><cfqueryparam cfsqltype="cf_sql_integer" value="1"></cfif> where EmpID = #EmployeeID#
        </cfquery>
       </cfif>
       
       using codlfusion.ajax.submitform you can submit to a cfc too.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
CERTIFIED EXPERT

Commented:
i am just confued with the query u have but the thing when u submit your form using coldfusion.ajax.submitform it will submit with our page refresh to the mentioned cfc or page.
 
 
erikTsomikSystem Architect, CF programmer

Author

Commented:
all i want to refresh is that particular column of the report
erikTsomikSystem Architect, CF programmer

Author

Commented:
when I execute the code i get an error
ColdFusion is Undefined. Is there something that i need to import first
CERTIFIED EXPERT

Commented:
you have coldfusion 8 right
CERTIFIED EXPERT

Commented:
coldfusion 8 and and when u instal coldfusion 8 u will get this folders
 
C:\Inetpub\wwwroot\CFIDE\scripts\ajax
erikTsomikSystem Architect, CF programmer

Author

Commented:
I can not Update the mapping to this path . Is there other way to import this library
CERTIFIED EXPERT

Commented:
u have cfide mapped in your iis
erikTsomikSystem Architect, CF programmer

Author

Commented:
yes . It mapped to /cfide
CERTIFIED EXPERT

Commented:
if coldfusion 8 in your root folder u should have CFIDE\scripts\ajax folder with js files
erikTsomikSystem Architect, CF programmer

Author

Commented:
OK . I lnkied to this folder now i get error saying that cfmessage is undefined
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.