Here's the point.
I load a page of all of my products details in my admin section so that my people can adjust product records.
All of the main product info comes from a table "bProducts"
Certain items come from other tables, like Manufacturer or Category or SUB category.
in my newly made subcat table, I am tieng the subcats to a manufacturer, other wise the list would be unwieldy.
Table has 3 columns
ManfID
SubCatID
SubCat
So my main edit product page, I pull everything based on Product ID. When I pull the info, I konw if the SubCategory field of bProducts is null or not null and load it into a recordset.
I then use a function to build the dropdown menu of subcats that fit the manu the product belongs to.
I am trying to make the drop down list have the current subcat be selected, then build the rest, but Im a real dummy about this stuff.
in bProducts, only the SubCatID exists.
SO I load it into my main RS and then feed it to my function
and here's the function
what's happening is the drop down list on the page is reading the SUBCATID (4 or 5 or 6 or whatever)
And i see why.
Its the line
tmp = tmp & "<option value='" & SubCat & "'>" & SubCat & "</option>"
It's loading the subcatID in the value (which is good) AND as the option, which is bad.
I tried changing it to this.
tmp = tmp & "<option value='" & SubCat & "'>" & objTmp("subcat") & "</option>"
That didn't work either,
How do i get that first option to read the correct SubCat that matches the fed subcatID?
I load a page of all of my products details in my admin section so that my people can adjust product records.
All of the main product info comes from a table "bProducts"
Certain items come from other tables, like Manufacturer or Category or SUB category.
in my newly made subcat table, I am tieng the subcats to a manufacturer, other wise the list would be unwieldy.
Table has 3 columns
ManfID
SubCatID
SubCat
So my main edit product page, I pull everything based on Product ID. When I pull the info, I konw if the SubCategory field of bProducts is null or not null and load it into a recordset.
I then use a function to build the dropdown menu of subcats that fit the manu the product belongs to.
I am trying to make the drop down list have the current subcat be selected, then build the rest, but Im a real dummy about this stuff.
in bProducts, only the SubCatID exists.
SO I load it into my main RS and then feed it to my function
Code:
<% Response.write SubCategoryDropDown(objRs("SubCategory")) %>
and here's the function
Code:
Function SubCategoryDropDown(SubCat)
'Returns HTML for a drop down list of manufacturers
On Error Resume Next
Dim tmp
Dim objTmp
Set objTmp = Server.Createobject("ADODB.Recordset")
objTmp.Open "SELECT * FROM bsubcat where ManfID=" & objRS("Manufacturer"), objCn, 1, 3
tmp = "<select name='SubCategory'>"
If SubCat <> "" Then
tmp = tmp & "<option value='" & SubCat & "'>" & SubCat & "</option>"
Do While Not objTmp.EOF
If Ucase(SubCat) <> Ucase(objTmp("bsubcatID")) Then tmp = tmp & "<option value='" & objTmp("bsubcatID") & "'>" & objTmp("subcat") & "</option>"
objTmp.MoveNext
Loop
else
Do While Not objTmp.EOF
tmp = tmp & "<option value='" & objTmp("bsubcatID") & "'>" & objTmp("subcat") & "</option>"
objTmp.MoveNext
Loop
end if
tmp = tmp & "</select>"
If Err.Number <> 0 Then
objTmp.Close
SubCategoryDropDown = ""
Else
objTmp.Close
SubCategoryDropDown = tmp
End If
End Function
what's happening is the drop down list on the page is reading the SUBCATID (4 or 5 or 6 or whatever)
And i see why.
Its the line
tmp = tmp & "<option value='" & SubCat & "'>" & SubCat & "</option>"
It's loading the subcatID in the value (which is good) AND as the option, which is bad.
I tried changing it to this.
tmp = tmp & "<option value='" & SubCat & "'>" & objTmp("subcat") & "</option>"
That didn't work either,
How do i get that first option to read the correct SubCat that matches the fed subcatID?