473,603 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("cmbPro duct")%>
<select name="cmbProduc t">
<option value="NULL" selected>Select a Product</option>
<%For iCtr = 1 to oProductList.Co unt
If CStr(oProductLi st.GetProduct(i Ctr).ID) = sProductID Then%>
<option value="<%=oProd uctList.GetProd uct(iCtr).ID%>"
selected><%=oPr oductList.GetPr oduct(iCtr).Nam e%></option>
<%else%>
<option
value="<%=oProd uctList.GetProd uct(iCtr).ID%>" ><%=oProductLis t.GetProduct(iC t
r).Name%></option>
<%End If
Next
Set oProductList = Nothing %>

Please suggest.

Thanks in advance
Prabhat

May 22 '06 #1
2 1653

"Prabhat" <no********@hot mail.com> wrote in message
news:OI******** ******@TK2MSFTN GP03.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("cmbPro duct")%>
<select name="cmbProduc t">
<option value="NULL" selected>Select a Product</option>
<%For iCtr = 1 to oProductList.Co unt
If CStr(oProductLi st.GetProduct(i Ctr).ID) = sProductID Then%>
<option value="<%=oProd uctList.GetProd uct(iCtr).ID%>"
selected><%=oPr oductList.GetPr oduct(iCtr).Nam e%></option>
<%else%>
<option
value="<%=oProd uctList.GetProd uct(iCtr).ID%>" ><%=oProductLis t.GetProduct(iC t 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_Initializ e()
Count = 3
ReDim GetProduct(3)
Set GetProduct(1) = New CProd
Set GetProduct(2) = New CProd
Set GetProduct(3) = New CProd
GetProduct(1).I D = 1
GetProduct(2).I D = 2
GetProduct(3).I D = 3
GetProduct(1).N ame = "First"
GetProduct(2).N ame = "Second"
GetProduct(3).N ame = "Third"
GetProduct(1).V ersion = "1.0"
GetProduct(2).V ersion = "1.1"
GetProduct(3).V ersion = "2.0"
End Sub
End Class

Dim oProductList: Set oProductList = New CList
Dim sProdID : sProdID = Request.QuerySt ring("cmbProduc t")

%>
<html>
<body>

<script type="text/javascript">

function cmdProduct_onch ange()
{

document.getEle mentById('spnPr odVer').innerHT ML =
this.options[this.selectedIn dex].getAttribute(" version")

}
</script>

<select id="cboProd" name="cmbProduc t"
onchange="cmdPr oduct_onchange. call(this)" >
<option <%=SelectedText ("", sProdID)%> >Select a Product</option>
<%

Dim oProd

For iCtr = 1 to oProductList.Co unt
Set oProd = oProductList.Ge tProduct(iCtr)
%>
<option value="<%=oProd .ID%>" <%=SelectedText (oProd.ID, sProdID)%>
version="<%=Ser ver.HTMLEncode( oProd.Version)% >"<%=Server.HTML Encode(oProd.Na me)%></option>

<%
Next

Function SelectedText(rs ID, rsProdID)
If CStr(rsID) = rsProdID Then
SelectedText = "selected"
Else
SelectedText = ""
End If
End Function

Function VersionText(roL ist, rsProdID)
If rsProdID <> "" Then
VersionText = roList.GetProdu ct(Clng(rsProdI D)).Version
End If
End Function
%>
</select>
<span class="version"
id="spnProdVer" ><%=Server.HTML Encode(VersionT ext(oProductLis t,
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_Initializ e()
Count = 3
ReDim GetProduct(3)
Set GetProduct(1) = New CProd
Set GetProduct(2) = New CProd
Set GetProduct(3) = New CProd
GetProduct(1).I D = 1
GetProduct(2).I D = 2
GetProduct(3).I D = 3
GetProduct(1).N ame = "First"
GetProduct(2).N ame = "Second"
GetProduct(3).N ame = "Third"
GetProduct(1).V ersion = "1.0"
GetProduct(2).V ersion = "1.1"
GetProduct(3).V ersion = "2.0"
End Sub
End Class

Dim oProductList: Set oProductList = New CList
Dim sProdID : sProdID = Request.QuerySt ring("cmbProduc t")

%>
<html>
<body>

<script type="text/javascript">

function cmdProduct_onch ange()
{

document.getEle mentById('spnPr odVer').innerHT ML =
this.options[this.selectedIn dex].getAttribute(" version")

}
</script>

<select id="cboProd" name="cmbProduc t"
onchange="cmdPr oduct_onchange. call(this)" >
<option <%=SelectedText ("", sProdID)%> >Select a Product</option>
<%

Dim oProd

For iCtr = 1 to oProductList.Co unt
Set oProd = oProductList.Ge tProduct(iCtr)
%>
<option value="<%=oProd .ID%>" <%=SelectedText (oProd.ID, sProdID)%>
version="<%=Ser ver.HTMLEncode( oProd.Version)% >"
><%=Server.HTML Encode(oProd.Na me)%></option>

<%
Next

Function SelectedText(rs ID, rsProdID)
If CStr(rsID) = rsProdID Then
SelectedText = "selected"
Else
SelectedText = ""
End If
End Function

Function VersionText(roL ist, rsProdID)
If rsProdID <> "" Then
VersionText = roList.GetProdu ct(Clng(rsProdI D)).Version
End If
End Function
%>
</select>
<span class="version"
id="spnProdVer" ><%=Server.HTML Encode(VersionT ext(oProductLis t,
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
2765
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 = fsockopen("tcp://$address", (int) $port, $errno, $errstr, 1); $extra = "extra=blah&this=test";
6
3140
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 how I can do this? When just adding them with ComboBox.items.Insert I get an "Items collection cannot be modified when the DataSource property is set". Does anybody has a solution for this? i'm surely not the first to do this :-) I'm using...
1
2201
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. The intent is to have the user enter in spend information by customer with each supplier. Sounds simple enough right? The common fields in each table are as follows:
8
12082
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 combobox. What is the solution? Thank you in advance.
6
4904
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 are not data bound (they just use the built in collection property of the ComboBox), and they are all set to use the DropDownList style. When moving from record to record via a BindingNavigator or a DataGridView (in master/detail format), the text...
2
8657
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 list of values from a table, and as the user selects values, a datagrid displays related records from another table because it is bound via FK relationship. My table: /****** Object: Table . Script Date: 06/19/2006
3
1535
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 function but i don't want to spend time with this if there is more simple way to do this. Thanks for all...
2
2895
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 transparent, and the other is a combobox called "Colours" that lists colours. The values in Colours depend on two differnet querys each based on tblColour. the query qTransparentColours shows all colours where the field Transparent is true and qSolidColours...
2
7136
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 filled in automatically by setting its .Text property equal to the .SelectedValue of the combobox. When the user enters an ID in the textbox the combobox's .SelectedValue is set to the .Text value in the ID textbox. All works fine but it is ...
0
7928
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8415
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8060
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6735
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5441
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3903
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1514
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.