473,401 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,401 software developers and data experts.

Sending Extra Value to ComboBox

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

May 22 '06 #1
2 1638

"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.
May 22 '06 #2
Hi Anthony,

It was great. Working as I expected. I never know about this technique in
ASP. Thanks for this. I will also study more on this

Thanks again
Prabhat
"Anthony Jones" wrote
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.

May 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: yawnmoth | last post by:
i'm trying to send an http post request and see if the server got it correctly. i'm sending the http post request with this script: <? $address = 'domain.tld'; $port = 80; $proxy =...
6
by: DraguVaso | last post by:
Hi, I have a ComboBox of +- 15.000 items in it, via a DataSource. On Top of the Items-list, I want to add some values, based on a user choise (via a filter on the DataSource). Does anybody know...
1
by: Trent | last post by:
I am in the design phase of a new database and am having a devil of a time with a subform. I have three tables that relate to problem - Suppliers tbl, Customers tbl and a SuppliersCustomers tbl....
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
6
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox...
2
by: shumaker | last post by:
I have a combobox that is very much like the one found in the RSS project here: http://msdn.microsoft.com/vstudio/express/visualCSharp/learning/ My projectNameComboBox basically is filled with a...
3
by: pegassi | last post by:
Hi, My question is that; is there any specified function to seperate multiple requests sending by combobox in a form? If yes can anybody explain me how? So I can make this by writting new...
2
by: mnms | last post by:
Hi, I'm wondering if it's possible "manually" add an extra value to a combobox list. At the moment I have two fields, one "transparent" is a checkbox that lets you define a colour as...
2
by: DesCF | last post by:
I have a textbox and a combobox on a toolstrip. The user enters either an ID in the textbox or selects a name from the combobox. When the user selects a name from the combobox the textbox is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.