listbox
Below is what i tried to do based on an example that i found. however, this code creates the listboxes at runtime and i don't want that. i want to add the listboxes in design and just add the items to it such as listbox1.add.item Also, with this code when i click a different category the subcategory doesn't change for some reason. I have also include the source that i get when i do view source. Why is tractor always repeated? If Not Page.IsPostBack Then Dim objconn As New ADODB.Connection objconn.Open(YBayTools.Constants.ConnectionString) Dim rsCAT As New ADODB.Recordset Dim sCategory Dim liCategory As New ListBox Dim liSubsCategory As New ListBox Dim AD_ID = "3059" Dim rsSubs As New ADODB.Recordset ' rsSubs.Open("SELECT * from SUBS where cat_ID = " & category.SelectedItem.Value.ToString, objconn) rsSubs.Open("select * from subs", objconn) rsCAT.Open("SELECT * FROM CATS ORDER BY cat_name ASC", objconn) If rsCAT.EOF Then Response.Write("No category.<BR>") Else ' write the CATEGORY listbox... Response.Write("<select id=""licategory"" SIZE=15" & _ " OnSelectedIndexChanged=""manuselected(this);"" >") ' write the entry code for the javascript... Dim sJavaScript = "function manuselected(elem){" & Environment.NewLine & _ "for (var i = liSubsCategory." & _ "options.length; i >= 0; i--){" & Environment.NewLine & _ "liSubsCategory.options = null;" & _ Environment.NewLine ' loop through the recordset... Do Until rsCAT.EOF ' is this a new category? Dim catname = rsCAT("cat_name").Value If (sCategory) <> "CATName" Then ' if so, add an entry to the first listbox sCategory = rsCAT("CAT_Name").Value Dim sCatId = rsCAT("CAT_ID").Value Response.Write("<OPTION VALUE=" & sCatId & ">" & sCategory & "</OPTION>") ' and add a new section to the javascript... sJavaScript = sJavaScript & "}" & Environment.NewLine & "if (elem.options[elem.selectedIndex].value==" & rsCAT("CAT_ID").Value & "){" & Environment.NewLine & "" End If ' and add a new SubsCategory line to the javascript... sJavaScript = sJavaScript & _ "liSubsCategory.options[" & _ "liSubsCategory.options.length] = new Option('" & _ rsSubs("sub_NAME").Value & "','" & rsSubs("sub_ID").Value & "');" & _ Environment.NewLine rsCAT.MoveNext() Loop ' finish the category listbox... Response.Write("</select>") liCategory.SelectedValue = 8 &nbs