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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, I got 2 combo boxes on my .asp file, the first one contains Categ

Status
Not open for further replies.

eyal

Programmer
May 15, 2000
38
IL
Hi,<br>I got 2 combo boxes on my .asp file, the first one contains Categories and the other sub categories, both are getting their values from an Access DB fields, my question is if I choose category 1 in the first combo box how can I fill the second combo box with the sub categories (field) that are relevant for category 1, or category 2 with sub categories 2 and so on?<br>Please be detailed cause I have no idea how to do that.<br>Thanks<br>Eyal<br>
 
Dear eyal,<br><br>Part of the solution is to filter the data from your access files using SQL statements. Do you know how to do that?<br><br>There are so many ways to implement your goal. <br><br>The simplest to code would probably be to go back to your .ASP page each time the user selects a different Category. You do this by implementing an onchange() handler for the &lt;select&gt; element of the categories. The idea is to set a hidden form value that indicates the operation to your server (asp) code.<br><br>&lt;form name=&quot;form1&quot; ...&gt;<br>&lt;select name=&quot;CategoryID&quot; onchange=&quot;mainCatChange()&quot;&gt;<br>&lt;option value=&quot;1&quot;&gt;Animal&lt;/option&gt;<br>&lt;option value=&quot;2&quot;&gt;Mineral&lt;/option&gt;<br>&lt;/select&gt;<br>&lt;input type=hidden value=0 name=&quot;EditMode&quot;&gt;<br>&lt;/form&gt;<br>&lt;script language=javascript&gt;<br>&lt;!--<br>function mainCatChange(){<br>&nbsp;&nbsp;document.form1.EditMode.value = &quot;1&quot;; <br>&nbsp;&nbsp;document.form1.submit();<br>}<br>//--&gt;<br>&lt;/script&gt;<br><br>Your .ASP code checks for a request variable named &quot;EditMode&quot; to contain the value 1. If it finds that it knows that all it should do is use the value of the request variable &quot;CategoryID&quot; to generate a SQL statement that will retrieve the corresponding rows to populate the other &lt;select&gt; tag with.<br><br>Hope this helps<br>-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top