Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to show all subcategory in one selected category

Status
Not open for further replies.

wminghao

Programmer
May 29, 2000
24
US
Hello:<br>&nbsp;<br>Can i get help about my problems in designing web pages of Coldfusion?<br>&nbsp;<br>In my Database, there is a table called Category ,contains all the three levels of categories in my listing. <br><br>each record has a category name and a parent which points to his father category.<br><br>However, I want to let users select one top category, then in the second category there will be all the subcategory in the first category he has selected. (Every topcategory selection there will be different sub categories for the user to select) <br><br>how to do with this in ONE coldfusion webpage?<br><br>I used query as :<br><br>&lt;!--- find the first level of category ---&gt;<br>&lt;cfquery&nbsp;&nbsp;&nbsp;name=&quot;AllLevel&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;datasource=&quot;#Session.sDBInfo[&quot;DataSource&quot;]#&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dbtype=&quot;#Session.sDBInfo[&quot;DBType&quot;]#&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username=&quot;#Session.sDBInfo[&quot;DBUserName&quot;]#&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password=&quot;#Session.sDBInfo[&quot;DBPassword&quot;]#&quot;&gt;<br>select&nbsp;&nbsp;DISTINCT C1.Name as C1Name, C2.Name as C2Name, C3.Name as C3Name<br>from Category C1, Category C2, Category C3<br>where C1.parent='Home' and C2.parent=C1.Name and C3.parent=C2.Name<br>&lt;/cfquery&gt; <br><br><br>&nbsp;<br>&nbsp;
 
I wish to show each category and its sub categories in one page.<br><br>For example; <br>When user select one category A, he can select the subcategory of A. Then he got A1,A2, A3. <br>If he doesn't select A, then he cannot select subcategory of A.<br><br>In my program, there is three level of categories, so a lot more complex.<br>&nbsp;<br>I tried to use this, but it doesn't work:<br><br>&lt;td&gt; <br>&nbsp;TopCategory <br>&nbsp;&lt;SELECT NAME=&quot;TopCategory&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&lt;cfoutput query=&quot;AllLevel&quot;&gt;<br>&nbsp;&nbsp;&nbsp; &lt;OPTION&gt;#C1Name#&lt;/OPTION&gt;<br>&nbsp;&nbsp;&nbsp;&lt;/cfoutput&gt;<br>&nbsp;&lt;/SELECT&gt;<br>&lt;/td&gt;<br>&lt;td&gt;<br>&nbsp;&nbsp;&nbsp;Category <br>&nbsp;&nbsp;&lt;select NAME=&quot;Category&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;cfoutput query=&quot;AllLevel&quot;&gt; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;OPTION&gt;#C2Name#&lt;/OPTION&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/cfoutput&gt;<br>&nbsp;&nbsp;&lt;/select&gt;<br>&lt;/td&gt;<br>&lt;td&gt;<br>&nbsp;&nbsp;&nbsp;SubCategory <br>&nbsp;&nbsp;&lt;select NAME=&quot;SubCategory&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;cfoutput query=&quot;AllLevel&quot;&gt; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;OPTION&gt;#C3Name#&lt;/OPTION&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;/cfoutput&gt;<br>&nbsp;&nbsp;&lt;/select&gt;<br>&lt;/td&gt;<br><br>Can u help me?<br>Thank you very very much!<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top