5 Replies - 16828 Views - Last Post: 26 June 2011 - 03:00 PM Rate Topic: -----

#1 chrisdonkor   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-June 11

CF_ThreeSelectsRelated duplicating main category values

Posted 26 June 2011 - 04:33 AM

I am trying to use CF_ThreeSelectsRelated on one of my websites. I got it to work but I realised that the first category is duplicating. I figured it is something I did wrong in the code but can't figure it out. Below is the code:


<CFQUERY DATASOURCE="#dbase#" NAME="TestQuery">
 SELECT 
 a.prodbrand_id, a.prodbrand_name,
 f.int_SubCategoryID, f.txt_SubCategory,
 r.int_ProductID, r.txt_ProductTitle
 FROM product_brands a, product_subcategories f, product_products r
 WHERE f.int_SubCategoryID = r.int_SubCategoryID
 AND a.prodbrand_id IN
 (SELECT prodbrand_id From product_brands
 WHERE a.prodbrand_id = f.prodbrand_id)
 ORDER BY r.txt_ProductTitle, f.txt_SubCategory, a.prodbrand_name
</CFQUERY>



<CFFORM>
<CF_ThreeSelectsRelated
 Query="TestQuery"
 Display1="prodbrand_name"
 Display2="txt_SubCategory"
 Display3="txt_ProductTitle"
 Value1="prodbrand_id"
 Value2="int_SubCategoryID"
 Value3="int_ProductID"
 EmptyText1="Pick Brand">
</CFFORM>





http://www.ezcomonli...electsTest.cfm.


I need help urgently.

Is This A Good Question/Topic? 0
  • +

Replies To: CF_ThreeSelectsRelated duplicating main category values

#2 Craig328   User is offline

  • I make this look good
  • member icon

Reputation: 2040
  • View blog
  • Posts: 3,621
  • Joined: 13-January 08

Re: CF_ThreeSelectsRelated duplicating main category values

Posted 26 June 2011 - 07:15 AM

Welcome to DIC, chrisdonkor!

CF_ThreeSelectsRelated is a custom tag that isn't part of the base CFML you're using. It was written a long time back by a fellow named Nate Weiss to address a need for one drop down to drive the contents of a subsequent drop down dynamically. It was written, though, because native CF didn't have a built in solution at the time to solve this problem. They still don't today but what they have is certainly more than flexible enough to solve your issue.

Your issue, incidentally, is not with the custom tag itself but probably with your query. Your issue is that you're not getting a distinct prodbrand_name/prodbrand_id for your first drop down. The tag probably evaluates display1/value1 combos first for distinctiveness (all the custom tag is doing for you is wrapping some medium strength Javascript selectors and arrays into a neat package) so my first guess would be to perhaps reverse your order by line in your query to first order it by the prodbrand_name, then txt_SubCategory and then txt_ProductTitle and see what you get.

A better way to perhaps handle it though, if re-ordering doesn't work, is to check out this entry on Ray Camden's blog, Triple Related Selects.

Good luck!
Was This Post Helpful? 0
  • +
  • -

#3 chrisdonkor   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-June 11

Re: CF_ThreeSelectsRelated duplicating main category values

Posted 26 June 2011 - 08:56 AM

Hello Craig328,

Thanks. When I reversed the order, it actually worked.

Am grateful
Was This Post Helpful? 0
  • +
  • -

#4 Craig328   User is offline

  • I make this look good
  • member icon

Reputation: 2040
  • View blog
  • Posts: 3,621
  • Joined: 13-January 08

Re: CF_ThreeSelectsRelated duplicating main category values

Posted 26 June 2011 - 09:27 AM

N/P. Glad to hear you got it working.
Was This Post Helpful? 0
  • +
  • -

#5 chrisdonkor   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 26-June 11

Re: CF_ThreeSelectsRelated duplicating main category values

Posted 26 June 2011 - 09:37 AM

Hello Craig328,

OK, I have encountered another problem. The select boxes are working fine. However, I am not able to insert the various IDs associated with my selection into the table on the action page. below is the action page code:

<CFQUERY name="AddData" datasource="#dbase#" dbtype="ODBC">
INSERT INTO products (prodbrand_id, int_subcategoryID, int_productID) 
VALUES
(#form.prodbrand_id#,
 #form.int_subcategoryID#,
 #form.int_productID#)
</CFQUERY>



thanks
Was This Post Helpful? 0
  • +
  • -

#6 Craig328   User is offline

  • I make this look good
  • member icon

Reputation: 2040
  • View blog
  • Posts: 3,621
  • Joined: 13-January 08

Re: CF_ThreeSelectsRelated duplicating main category values

Posted 26 June 2011 - 03:00 PM

Do a view source of your form page and then check to see what each select form element is named.

They're not what you're trying to input into your form. Also, whenever you encounter a problem like that, consider doing a debugging dump of the form scope like this:

<cfdump var="#form#">


Try that and you should see your problem straight away.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1