House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home / Groups / Ajax

Ajax and ColdFusion

Author:
erik tom
11/08/2007 02:10 PM

In my form I am trying to implement Up/Down movement and store the changes into database without refreshing the page. In order to accomplish this I would like tio use Ajax . So that what I came up with Hidden variable: <cfoutput> <input type="hidden" Name="FieldsSave" id="FieldsSave"></cfoutput> 2 buttons <input type="button" id="moveUp" name="moveUp" value="MoveUp" onclick="javascript:Field_up(document.category.categorylist,document.category.FieldsSave)"> <input type="button" id="moveDown" name="moveDown" value="moveDown" onclick="javascript:Field_down(document.category.categorylist,document.category.FieldsSave)">        The functions assosiated withing the function function Field_up(lst,lstSave) { var i = lst.selectedIndex; if (i>0) Field_swap(lst,i,i-1); SetFields(lst,lstSave); } function Field_down(lst,lstSave) { var i = lst.selectedIndex; if (i<lst.length-1) Field_swap(lst,i+1,i); SetFields(lst,lstSave); } function Field_swap(lst,i,j) { var t = ''; t = lst.options[i].text; lst.options[i].text = lst.options[j].text; lst.options[j].text = t; t = lst.options[i].value; lst.options[i].value = lst.options[j].value; lst.options[j].value = t; t = lst.options[i].selected; lst.options[i].selected = lst.options[j].selected; lst.options[j].selected = t; t = lst.options[i].defaultSelected; lst.options[i].defaultSelected = lst.options[j].defaultSelected; lst.options[j].defaultSelected = t; //lst.focus(); } function SetFields(lst,lstSave) { var t; lstSave.value=""; for (t=0;t<=lst.length-1;t++) lstSave.value+=String(lst.options[t].value)+","; //lst.focus(); if (lstSave.value.length>0) lstSave.value=lstSave.value.slice(0,-1); } The CF server file: <cfparam name="form.FieldsSave" default=""> <cfif isDefined("form.moveUp") or isDefined("form.moveDown")> <cfset Order=1> <cfloop list="#Form.FieldsSave#" index="field"> <cfquery name="SetOrder" datasource="XXXXXXX"> UPDATE trnAcademicProgramCategory SET categorySort = #Order# WHERE  categoryId=#field# and schoolCode='#session.schoolcode#' </cfquery> <cfset Order = Order + 1> </cfloop> </cfif>


Search ajax

July 28, 2014

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference