Is it possible to return a database query without refreshing the page?
i have form has drop-down select box. want send value select list cfc runs sql code , returns recordset. want use recordset on original cfm page has form on it.
is possible without refreshing page through kind of ajax? apologies newbie @ ajax did manage write bit of code uses <cfdiv> bind url database work , returns html. want database recordset , not sure how it?
you use ajax, flex remoting or such remoting technique. is, if there case it. however, describe in first paragraph, don't need to. send form own page.
in following example, cfc , cfm page both in same directory under root. have made use of cfdocexamples datasource ships coldfusion.
employee.cfc
<cfcomponent>
<cffunction name="getemployeedetails" output="false" returntype="query">
<cfargument name="employee_id">
<cfset var employeedetails = querynew("","")>
<cfset var emp_id = arguments.employee_id>
<cfif isnumeric(emp_id)>
<cfquery name = "employeedetails" datasource = "cfdocexamples">
select firstname, email email_name, department, phone, location
employees
emp_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#emp_id#">
</cfquery>
</cfif>
<!--- activate error-handler in caller --->
<cfif not isnumeric(emp_id) or employeedetails.recordcount eq 0>
<cfthrow message="you selected no employee.">
</cfif>
<cfreturn employeedetails>
</cffunction>
</cfcomponent>
testpage.cfm
<cfif isdefined("form.employee_id")>
<cfset employeeobj = createobject("component","employee")>
<!--- employeedetails query--->
<cfset employeedetails = employeeobj.getemployeedetails(form.employee_id)>
<cfdump var="#employeedetails#">
</cfif>
<cfform action="#cgi.script_name#">
<cfselect name="employee_id">
<option value="0">employee</option>
<option value="1">carolynn petersen</option>
<option value="2">dave heartside</option>
<option value="3">linda stewart</option>
</cfselect>
<cfinput name="sbmt" type="submit" value="send">
</cfform>
More discussions in ColdFusion
adobe
Comments
Post a Comment