coldfusion - Pass form value to cfc -
i have cfc function returns query list of employees displayed in table. have sorting form on page, onclick of column heading data needs sorted based on column being clicked. now, had working long queries on page itself. trying move queries cfc now. sure missing basic here. can please point me how sorted results cfc onclick of column header?
<script> function submitformnow(x){ if (document.form.show.value == "desc") {$('input[name=show]').val('asc');} else{ $('input[name=show]').val('desc');} $('input[name=order_by]').val(x); document.form.submit(); } </script> <cffunction name="getemps" access="public" output="false" returntype="query"> <cfargument name="emp_id" type="numeric" default="#variables.emp_id#" /> <cfargument name="order_by" default="#variables.order_by#" type="string" required="no"> <cfargument name="show" default="#variables.show#" type="string" required="no"> <cfquery name="qemps" datasource="test"> select * emps <cfif len(trim(arguments.order_by)) , arguments.order_by neq '' , len(trim(arguments.show)) , arguments.show neq '' > order #arguments.order_by# #arguments.show# </cfif> </cfquery> </cffunction> <cfset employee= new cfcs.employees() /> <cfset getemps = employee.getemps(emp_id,order_by,show) />//order_by, show form field here//
try
<cfset getemps = employee.getemps(form.emp_id,form.order_by,form.show)>
also remember form. variables, before referencing them make sure exist.
<cfparam name="form.emp_id" default=0> <cfparam name="form.order_by" default=""> <cfparam name="form.show" default="asc"> <cfset getemps = employee.getemps(form.emp_id,form.order_by,form.show)>
Comments
Post a Comment