Re: Update database by moving selection up and down
As I said that example is rather old, it looks like the second parameter should be the name of the field to save the values into. Could just delete it and hard code the name of the field to save to. I do not have my tag handy from work right now or I'd just send it to you. On 10/5/07, erik tom <[EMAIL PROTECTED]> wrote: > > >Why do you have Form.requirements in your where clause? You would be > >looping over a LIST of unique IDs and referencing the loop's index in > your > >where clause. Change the index name for the loop and reference that in > the > >where clause then see what happens. > > > > > >> > Nothing is happening. Also I noticed that in the JS function once it hits > to for loop execution is over. And one more thing onsubmit the function > required 2 parameters and we passing only 1 > function SetFields(lst,lstSave) { > var t; > lstSave.value=""; > for (t=0;t<=lst.length-1;t++){ > lstSave.value+=String(lst.options[t].value)+","; > if (lstSave.value.length>0) > lstSave.value=lstSave.value.slice(0,-1); > } > } > > ~| Create robust enterprise, web RIAs. Upgrade to ColdFusion 8 and integrate with Adobe Flex http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290397 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Update database by moving selection up and down
>Why do you have Form.requirements in your where clause? You would be >looping over a LIST of unique IDs and referencing the loop's index in your >where clause. Change the index name for the loop and reference that in the >where clause then see what happens. > > >> Nothing is happening. Also I noticed that in the JS function once it hits to for loop execution is over. And one more thing onsubmit the function required 2 parameters and we passing only 1 function SetFields(lst,lstSave) { var t; lstSave.value=""; for (t=0;t<=lst.length-1;t++){ lstSave.value+=String(lst.options[t].value)+","; if (lstSave.value.length>0) lstSave.value=lstSave.value.slice(0,-1); } } ~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290392 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Update database by moving selection up and down
Why do you have Form.requirements in your where clause? You would be looping over a LIST of unique IDs and referencing the loop's index in your where clause. Change the index name for the loop and reference that in the where clause then see what happens. On 10/5/07, erik tom <[EMAIL PROTECTED]> wrote: > > > this code does not work for me. Here is what I did. I copied this function > function SetFields(lst,lstSave) { > var t; > lstSave.value="" > for (t=0;t<=lst.length-1;t++) > lstSave.value+=String(lst.options[t].value)+","; > if (lstSave.value.length>0) > lstSave.value=lstSave.value.slice(0,-1); > } > I added onsubmit="SetFields(document.combo_box.requirements);" to my form > tag > I added > And also added this > > > > > > UPDATE trnAcademicProgramsAndRequirementsMapping > SET SortOrder = #Order# > WHERE reqid = #form.requirements# and degreeid=#form.program# > > > > > However I do not get any errors but nothing get updated > > > ~| Get the answers you are looking for on the ColdFusion Labs Forum direct from active programmers and developers. http://www.adobe.com/cfusion/webforums/forum/categories.cfm?forumid-72&catid=648 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290345 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Update database by moving selection up and down
>Here you go, someone apparently asked me a long time ago since the content >of my site is probably a good 5 years old. Probably a better way to do >this, but like I said I just keep reusing the same custom tag for it here >since it works. > >http://www.happyhacker.com/WebDev.cfm?Cat=CF&SubCat=Ordering#StartHere > > >> this code does not work for me. Here is what I did. I copied this function function SetFields(lst,lstSave) { var t; lstSave.value="" for (t=0;t<=lst.length-1;t++) lstSave.value+=String(lst.options[t].value)+","; if (lstSave.value.length>0) lstSave.value=lstSave.value.slice(0,-1); } I added onsubmit="SetFields(document.combo_box.requirements);" to my form tag I added And also added this UPDATE trnAcademicProgramsAndRequirementsMapping SET SortOrder = #Order# WHERE reqid = #form.requirements# and degreeid=#form.program# However I do not get any errors but nothing get updated ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290325 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Update database by moving selection up and down
erik tom wrote: > Tell me how. I am calling the function like this name="moveUp" onclick="moveUp(-1)"> and the same for movedown . And it works > my question is how can i update the database > With your "moveUp(-1)" call, are you passing just a -1 or are you also passing whatever unique DB identifier of the item you're trying to move up? If not, you're going to need to do that, at the very least. Or, pass in the unique IDs of the two items affected - i.e. move(#currentItemID#, #previous or next itemID#) (previous if you're doing a move up, next if you're doing a move down) That way you know which two items to switch. Pass those values on to your next script, where you do the DB calls to switch the vals - you get the order-by values for the two IDs, and then update both records with each other's order-by values. SELECT ID, OrderBy FROM yourTable WHERE ID IN (#firstIDpassed#, #secondIDpassed#) UPDATE yourTable SET OrderBy = #getOrderBy.OrderBy[2]# WHERE ID = #getOrderBy.ID[1]# UPDATE yourTable SET OrderBy = #getOrderBy.OrderBy[1]# WHERE ID = #getOrderBy.ID[2]# ~| Create robust enterprise, web RIAs. Upgrade to ColdFusion 8 and integrate with Adobe Flex http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290314 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Update database by moving selection up and down
Here you go, someone apparently asked me a long time ago since the content of my site is probably a good 5 years old. Probably a better way to do this, but like I said I just keep reusing the same custom tag for it here since it works. http://www.happyhacker.com/WebDev.cfm?Cat=CF&SubCat=Ordering#StartHere On 10/5/07, erik tom <[EMAIL PROTECTED]> wrote: > > >I think he is asking how to get what is submitted into the database, not > how > >to submit the form itself. > > > >I am guessing this is just a mult-select being submitted. What I have > done > >in the past is when I submit the form I run a JS function that grabs the > >values(which are the PKs for what is displayed) of my options and > >concatenate them into a list that is passed as a hidden form element. I > >then on the processing side loop through that and update the PK to the > >placement in the list. Might be a much better way to do this, I have > just > >reused the same script for this for the past 8 years or so, never had a > need > >to rewrite it. > > > > > >> > can you provide me with the sample of your script > > ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290306 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Update database by moving selection up and down
>I think he is asking how to get what is submitted into the database, not how >to submit the form itself. > >I am guessing this is just a mult-select being submitted. What I have done >in the past is when I submit the form I run a JS function that grabs the >values(which are the PKs for what is displayed) of my options and >concatenate them into a list that is passed as a hidden form element. I >then on the processing side loop through that and update the PK to the >placement in the list. Might be a much better way to do this, I have just >reused the same script for this for the past 8 years or so, never had a need >to rewrite it. > > >> can you provide me with the sample of your script ~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290285 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Update database by moving selection up and down
I think he is asking how to get what is submitted into the database, not how to submit the form itself. I am guessing this is just a mult-select being submitted. What I have done in the past is when I submit the form I run a JS function that grabs the values(which are the PKs for what is displayed) of my options and concatenate them into a list that is passed as a hidden form element. I then on the processing side loop through that and update the PK to the placement in the list. Might be a much better way to do this, I have just reused the same script for this for the past 8 years or so, never had a need to rewrite it. On 10/4/07, Brian Kotek <[EMAIL PROTECTED]> wrote: > > I'm afraid you're not making sense. You want to know how to submit a form > to > the server? Use a submit button. Or a JavaScript function that submits the > form ( > > http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml > ). > > On 10/4/07, erik tom <[EMAIL PROTECTED]> wrote: > > > > >Submit the form or execute an AJAX request. > > > > > > > > >> > > Tell me how. I am calling the function like this > name="moveUp" onclick="moveUp(-1)"> and the same for movedown . And it > works > > my question is how can i update the database > > > > > > ~| Download the latest ColdFusion 8 utilities including Report Builder, plug-ins for Eclipse and Dreamweaver updates. http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290253 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Update database by moving selection up and down
I'm afraid you're not making sense. You want to know how to submit a form to the server? Use a submit button. Or a JavaScript function that submits the form ( http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml ). On 10/4/07, erik tom <[EMAIL PROTECTED]> wrote: > > >Submit the form or execute an AJAX request. > > > > > >> > Tell me how. I am calling the function like this name="moveUp" onclick="moveUp(-1)"> and the same for movedown . And it works > my question is how can i update the database > > ~| Enterprise web applications, build robust, secure scalable apps today - Try it now ColdFusion Today ColdFusion 8 beta - Build next generation apps Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290251 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Update database by moving selection up and down
>Submit the form or execute an AJAX request. > > >> Tell me how. I am calling the function like this and the same for movedown . And it works my question is how can i update the database ~| ColdFusion 8 - Build next generation apps today, with easy PDF and Ajax features - download now http://download.macromedia.com/pub/labs/coldfusion/cf8_beta_whatsnew_052907.pdf Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290250 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Update database by moving selection up and down
Submit the form or execute an AJAX request. On 10/4/07, erik tom <[EMAIL PROTECTED]> wrote: > > I have a drop down menu which does add remove functions from 1 drop down > to another , and aslo have up and down arrows which do the respective > movement. Now I need to find a way how to update the sort order in the > database if I move the item up/down. The application is written IN CF. > Here is my move script > function moveUpDown(to) { > var list2 = document.forms[0].requirements; > var index = list2.selectedIndex; > var total = list2.options.length-1; > if (index == -1) return false; > if (to == +1 && index == total) return false; > if (to == -1 && index == 0) return false; > var items = new Array; > var values = new Array; > for (i = total; i >= 0; i--) { > items[i] = list2.options[i].text; > values[i] = list2.options[i].value; > } > for (i = total; i >= 0; i--) { > if (index == i) { > list2.options[i + to] = new Option(items[i],values[i + to], 0, > 1); > list2.options[i] = new Option(items[i + to], values[i]); > i--; > } > else { > list2.options[i] = new Option(items[i], values[i]); > } > } > list2.focus(); > } > > > ~| ColdFusion is delivering applications solutions at at top companies around the world in government. Find out how and where now http://www.adobe.com/cfusion/showcase/index.cfm?event=finder&productID=1522&loc=en_us Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290232 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Update database by moving selection up and down
I have a drop down menu which does add remove functions from 1 drop down to another , and aslo have up and down arrows which do the respective movement. Now I need to find a way how to update the sort order in the database if I move the item up/down. The application is written IN CF. Here is my move script function moveUpDown(to) { var list2 = document.forms[0].requirements; var index = list2.selectedIndex; var total = list2.options.length-1; if (index == -1) return false; if (to == +1 && index == total) return false; if (to == -1 && index == 0) return false; var items = new Array; var values = new Array; for (i = total; i >= 0; i--) { items[i] = list2.options[i].text; values[i] = list2.options[i].value; } for (i = total; i >= 0; i--) { if (index == i) { list2.options[i + to] = new Option(items[i],values[i + to], 0, 1); list2.options[i] = new Option(items[i + to], values[i]); i--; } else { list2.options[i] = new Option(items[i], values[i]); } } list2.focus(); } ~| Download the latest ColdFusion 8 utilities including Report Builder, plug-ins for Eclipse and Dreamweaver updates. http;//www.adobe.com/cfusion/entitlement/index.cfm?e=labs%5adobecf8%5Fbeta Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:290230 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4