Re: Help with List Comparisons, Output Logic
On 3/28/07, Joel W wrote: > Never mind--I have simply added a hidden ID field in the form's looped > section (the one The only thing I'd add is that you should probably cfqueryparam those values too... It's easier to forget when doing loops and stuff, but just as needed. /me goes back to whipping up a bit of offense for chr(124)+userID>0 requests... [ Just kidding about offense. =] ~| Create Web Applications With ColdFusion MX7 & Flex 2. Build powerful, scalable RIAs. Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:274015 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Help with List Comparisons, Output Logic
Never mind--I have simply added a hidden ID field in the form's looped section (the one handling the checkbox generation...) Anyway, I set up my database per your suggestion, and it is working brilliantly! I am handling the looped Insert statement like this: feel free to let me know if it can be done in an easier way: SELECT * FROM Pages ORDER BY PageName ASC INSERT INTO Links (LogoID, PageID, Checked) VALUES ( '#FORM.LogoID#', '#ListGetAt(pageIDList, Counter)#', '#ListGetAt(checkedList, Counter)#' ) Anyway, thanks for all of the help. I really do appreciate it! Joel >If you are returning a POST instead of a GET, I'd name all the >checkboxes the same. Make the values the page IDs. You'll get a >comma-delimited list which you can parse into a large insert. > >If you have to name them individually, prefix them with something >similar (ie page_(ID) so, page_23, page_9, etc.). You can loop over the >formfields list and extract them. > >Sorry if that's not clear, but I'm pretty tired. :-) > >--Ben > >Joel Watson wrote: >> ~| Create robust enterprise, web RIAs. Upgrade & integrate Adobe Coldfusion MX7 with Flex 2 http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273964 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Help with List Comparisons, Output Logic
DOH! Part of my problem thus far is that I've been using a flash form which apparently doesn't pass the "value" of a check box, only the boolean state (and all of them, for that matter, checked or unchecked)... Is this able to be circumvented, or should I adjust the tables which I am creating? >If you are returning a POST instead of a GET, I'd name all the >checkboxes the same. Make the values the page IDs. You'll get a >comma-delimited list which you can parse into a large insert. > >If you have to name them individually, prefix them with something >similar (ie page_(ID) so, page_23, page_9, etc.). You can loop over the >formfields list and extract them. > >Sorry if that's not clear, but I'm pretty tired. :-) > >--Ben > >Joel Watson wrote: >> ~| Upgrade to Adobe ColdFusion MX7 The most significant release in over 10 years. Upgrade & see new features. http://www.adobe.com/products/coldfusion?sdid=RVJR Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273958 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Help with List Comparisons, Output Logic
If you are returning a POST instead of a GET, I'd name all the checkboxes the same. Make the values the page IDs. You'll get a comma-delimited list which you can parse into a large insert. If you have to name them individually, prefix them with something similar (ie page_(ID) so, page_23, page_9, etc.). You can loop over the formfields list and extract them. Sorry if that's not clear, but I'm pretty tired. :-) --Ben Joel Watson wrote: > Ben, Dinner-- > > Thank you both for the erudite responses. You have convinced me! > > Now for the million-dollar question: > > As mentioned, I am generating the select boxes dynamically from the "Pages" > table. If I am to enter the users inputs from the check boxes, how would I > go about parsing out these multiple selections to separate database entries? > Initially, I thought > about using a database, but this was something I did not know how to do. Any > suggestions? > > (BTW, I am dyanamically naming the checkboxes with the "Page" Id...if that > helps). > > Thanks again for your great help! > > Joel > >> Sounds to me like you need a relationship table! >> >> Get away from the list of values, and instead use a separate table, >> with a relation table, which links the two together. >> >> For the one-offs (if I'm even using that term right) it's no big deal, but >> if you're going to be doing a fair bit of stuff with the data... you are >> really going to want to "normalize" it. >> >> MySQL has some fancy and amazingly helpful functions for working >> with "list of values" type fields, but still, it's a best practice to >> normalize >> wherever you can... >> >> Damn you Ben! GMail just pinged me, and I'm betting you just suggested >> the same damn thing... yup. Oh well. I'll post this anyway, for emphasis. >> (Not conditioning! ;) >> >> On 3/27/07, Joel W wrote: >>> Thanks for the response. One of the issues I am running into is that (and >>> I failed to > > ~| Macromedia ColdFusion MX7 Upgrade to MX7 & experience time-saving features, more productivity. http://www.adobe.com/products/coldfusion?sdid=RVJW Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273949 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Help with List Comparisons, Output Logic
Ben, Dinner-- Thank you both for the erudite responses. You have convinced me! Now for the million-dollar question: As mentioned, I am generating the select boxes dynamically from the "Pages" table. If I am to enter the users inputs from the check boxes, how would I go about parsing out these multiple selections to separate database entries? Initially, I thought about using a database, but this was something I did not know how to do. Any suggestions? (BTW, I am dyanamically naming the checkboxes with the "Page" Id...if that helps). Thanks again for your great help! Joel >Sounds to me like you need a relationship table! > >Get away from the list of values, and instead use a separate table, >with a relation table, which links the two together. > >For the one-offs (if I'm even using that term right) it's no big deal, but >if you're going to be doing a fair bit of stuff with the data... you are >really going to want to "normalize" it. > >MySQL has some fancy and amazingly helpful functions for working >with "list of values" type fields, but still, it's a best practice to normalize >wherever you can... > >Damn you Ben! GMail just pinged me, and I'm betting you just suggested >the same damn thing... yup. Oh well. I'll post this anyway, for emphasis. >(Not conditioning! ;) > >On 3/27/07, Joel W wrote: >> Thanks for the response. One of the issues I am running into is that (and I >> failed to ~| Create Web Applications With ColdFusion MX7 & Flex 2. Build powerful, scalable RIAs. Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273944 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Help with List Comparisons, Output Logic
Sounds to me like you need a relationship table! Get away from the list of values, and instead use a separate table, with a relation table, which links the two together. For the one-offs (if I'm even using that term right) it's no big deal, but if you're going to be doing a fair bit of stuff with the data... you are really going to want to "normalize" it. MySQL has some fancy and amazingly helpful functions for working with "list of values" type fields, but still, it's a best practice to normalize wherever you can... Damn you Ben! GMail just pinged me, and I'm betting you just suggested the same damn thing... yup. Oh well. I'll post this anyway, for emphasis. (Not conditioning! ;) On 3/27/07, Joel W wrote: > Thanks for the response. One of the issues I am running into is that (and I > failed to ~| Upgrade to Adobe ColdFusion MX7 Experience Flex 2 & MX7 integration & create powerful cross-platform RIAs http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJQ Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273942 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Help with List Comparisons, Output Logic
It might make a lot more sense to use another table to store these values, instead of trying to build vague "true, true, false" lists. You'd store, in addition to the PK for this table (because every table has a PK, right? RIGHT?) the PKs for the page and sponsor that are connected. That is, if Sponsor 1 wants pages 3 and 4 and Sponsor 2 wants pages 4 and 5 you might end up with a table like this: LinkID SponsorID PageID 1 1 3 2 1 4 3 2 4 4 2 5 Does this make sense? --Ben Doom Joel Watson wrote: > Thanks for the response. One of the issues I am running into is that (and I > failed to mention this in my original post) the checkboxes are being > dynamically generated from another table called "Pages." So then, for > whatever reason, my list is being wr > itten with values for every checkbox, regardless of whether they are checked > or not. > > So, if have checkboxes "index", "localnews" and "sports", i will get a list > with a number of items which match the selections and non-selections > (e.g.,"true,true,false"). > > One solution that I tried was using radio buttons instead in order to submit > the actual page names (e.g., instead of "true,true,false," submit > "index,localnews,sports"). However, I found that if I did not select a > particular item--say, "obituaries"--on > submit I would be thrown a scope error. > > If I could get this method to work, it would be great. Unfortunately, at the > present the only luck I've had is to submit the boolean values of the > checkbox. Obviously, this leaves me in the predicament mentioned before in > needing to find a way to loop > over each list of each sponsor in order to display on the proper pages. > > Any other ideas? > > >> (Your message is a bit confusing, but I'll go with what I think you might be >> asking) >> >> Unselected checkboxes are never submitted, so you'll only ever get a list of >> trues. >> >> Set the values of the checkboxes to the id's of the items. >> >> Then you wont need do any looping, you'll just do this: >> >> >> SELECT * >>FROM sponsors >> WHERE pagename IN () >> >> >> >> (Or something along those lines) >> >> >>> Joel > > ~| ColdFusion MX7 by AdobeĀ® Dyncamically transform webcontent into Adobe PDF with new ColdFusion MX7. Free Trial. http://www.adobe.com/products/coldfusion?sdid=RVJV Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273941 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: Help with List Comparisons, Output Logic
Thanks for the response. One of the issues I am running into is that (and I failed to mention this in my original post) the checkboxes are being dynamically generated from another table called "Pages." So then, for whatever reason, my list is being written with values for every checkbox, regardless of whether they are checked or not. So, if have checkboxes "index", "localnews" and "sports", i will get a list with a number of items which match the selections and non-selections (e.g.,"true,true,false"). One solution that I tried was using radio buttons instead in order to submit the actual page names (e.g., instead of "true,true,false," submit "index,localnews,sports"). However, I found that if I did not select a particular item--say, "obituaries"--on submit I would be thrown a scope error. If I could get this method to work, it would be great. Unfortunately, at the present the only luck I've had is to submit the boolean values of the checkbox. Obviously, this leaves me in the predicament mentioned before in needing to find a way to loop over each list of each sponsor in order to display on the proper pages. Any other ideas? >(Your message is a bit confusing, but I'll go with what I think you might be >asking) > >Unselected checkboxes are never submitted, so you'll only ever get a list of >trues. > >Set the values of the checkboxes to the id's of the items. > >Then you wont need do any looping, you'll just do this: > > >SELECT * >FROM sponsors >WHERE pagename IN () > > > >(Or something along those lines) > > >> Joel ~| Create robust enterprise, web RIAs. Upgrade & integrate Adobe Coldfusion MX7 with Flex 2 http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273939 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: Help with List Comparisons, Output Logic
(Your message is a bit confusing, but I'll go with what I think you might be asking) Unselected checkboxes are never submitted, so you'll only ever get a list of trues. Set the values of the checkboxes to the id's of the items. Then you wont need do any looping, you'll just do this: SELECT * FROM sponsors WHERE pagename IN () (Or something along those lines) > I have a fairly complex problem I am trying to solve. > > I have a form for creating sponsors. On this form, the user is given > a series of checkboxes for selecting which page(s) they would like the > sponsor's advertisement to display. On submission, the selected check > boxes are written to a list which is stored under the sponsor's table > in my database, with "true" or "false" for the given pagename in the > list(e.g., if I have the pagenames index, birthday, & sports, the list > will be output as "true,true,true" if the user chooses all of them). > > I am having difficulty with the output--how would I loop over all the > entries in my sponsors table to display only the sponsors where the > first list item is "true"? > > I have tried to craft an cfif statement to catch the criterion, but I > have not had any luck. Any ideas? > > Thanks! > > Joel ~| Create Web Applications With ColdFusion MX7 & Flex 2. Build powerful, scalable RIAs. Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273933 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Help with List Comparisons, Output Logic
I have a fairly complex problem I am trying to solve. I have a form for creating sponsors. On this form, the user is given a series of checkboxes for selecting which page(s) they would like the sponsor's advertisement to display. On submission, the selected check boxes are written to a list which is stored under the sponsor's table in my database, with "true" or "false" for the given pagename in the list(e.g., if I have the pagenames index, birthday, & sports, the list will be output as "true,true,true" if the user chooses all of them). I am having difficulty with the output--how would I loop over all the entries in my sponsors table to display only the sponsors where the first list item is "true"? I have tried to craft an cfif statement to catch the criterion, but I have not had any luck. Any ideas? Thanks! Joel ~| Create Web Applications With ColdFusion MX7 & Flex 2. Build powerful, scalable RIAs. Free Trial http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJS Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:273927 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4