"Prabhat" <no********@hotmail.com> wrote in message
news:OI**************@TK2MSFTNGP03.phx.gbl...
Hi all,
I have one combobox where I want to display Name of the Products that are
loaded in the collection object. But I am able to send only ID and Name of
the Product where ID is the value of the option tag and products name is
the display text for option tag. I want to send the Product Version Number to
clients browser for ALL Products that are loaded to combobox so that On
Change of the combobox the Version Number should display in one of the
Edit Box. How can I do that?
Code fragment that loads the Products to ComboBox:
<%sProductID = Request("cmbProduct")%>
<select name="cmbProduct">
<option value="NULL" selected>Select a Product</option>
<%For iCtr = 1 to oProductList.Count
If CStr(oProductList.GetProduct(iCtr).ID) = sProductID Then%>
<option value="<%=oProductList.GetProduct(iCtr).ID%>"
selected><%=oProductList.GetProduct(iCtr).Name%></option>
<%else%>
<option
value="<%=oProductList.GetProduct(iCtr).ID%>"><%=o ProductList.GetProduct(iCt r).Name%></option>
<%End If
Next
Set oProductList = Nothing %>
Please suggest.
Thanks in advance
Prabhat
Here is a mock up:-
<%
Class CProd
Public Name
Public ID
Public Version
End Class
Class CList
Public Count
Public GetProduct
Private Sub Class_Initialize()
Count = 3
ReDim GetProduct(3)
Set GetProduct(1) = New CProd
Set GetProduct(2) = New CProd
Set GetProduct(3) = New CProd
GetProduct(1).ID = 1
GetProduct(2).ID = 2
GetProduct(3).ID = 3
GetProduct(1).Name = "First"
GetProduct(2).Name = "Second"
GetProduct(3).Name = "Third"
GetProduct(1).Version = "1.0"
GetProduct(2).Version = "1.1"
GetProduct(3).Version = "2.0"
End Sub
End Class
Dim oProductList: Set oProductList = New CList
Dim sProdID : sProdID = Request.QueryString("cmbProduct")
%>
<html>
<body>
<script type="text/javascript">
function cmdProduct_onchange()
{
document.getElementById('spnProdVer').innerHTML =
this.options[this.selectedIndex].getAttribute("version")
}
</script>
<select id="cboProd" name="cmbProduct"
onchange="cmdProduct_onchange.call(this)" >
<option <%=SelectedText("", sProdID)%> >Select a Product</option>
<%
Dim oProd
For iCtr = 1 to oProductList.Count
Set oProd = oProductList.GetProduct(iCtr)
%>
<option value="<%=oProd.ID%>" <%=SelectedText(oProd.ID, sProdID)%>
version="<%=Server.HTMLEncode(oProd.Version)%>"<%=Server.HTMLEncode(oProd.Name)%></option>
<%
Next
Function SelectedText(rsID, rsProdID)
If CStr(rsID) = rsProdID Then
SelectedText = "selected"
Else
SelectedText = ""
End If
End Function
Function VersionText(roList, rsProdID)
If rsProdID <> "" Then
VersionText = roList.GetProduct(Clng(rsProdID)).Version
End If
End Function
%>
</select>
<span class="version"
id="spnProdVer"><%=Server.HTMLEncode(VersionText(o ProductList,
sProdID))%></span>
</body>
</html>
Anthony.