Hi,
I am Using 2 combo i am filling 1st combo through data base value like company name.
i want to fill the name of employee in second combo when i select company name from first combo
can any body help me in this regards.
2 3265
u use ajax script 2 load the second combo box
sashi 1,754
Recognized Expert Top Contributor
Hi there,
Kindly refer to below sample code segment, hope it helps, take care my fren.. :) -
<!-- #include file="adovbs.inc" -->
-
<%
-
Dim strSQL
-
Dim cnnSalesDB
-
Dim rstSalesmen, rstSales
-
Dim iRequestedID
-
-
' Some basic checking and cleaning of the input
-
iRequestedID = Trim(Request.QueryString("id"))
-
iRequestedID = Replace(iRequestedID, "'", "''")
-
-
If IsNumeric(iRequestedID) Then
-
iRequestedID = CInt(iRequestedID)
-
Else
-
iRequestedID = 0
-
End If
-
-
' The form links back to this same file passing back the id
-
%>
-
<p>
-
Pick a salesman to see the details of one of their sales:
-
</p>
-
<form action="db_pulldown_linked.asp" method="get">
-
<%
-
-
' Create ADO data connection object
-
Set cnnSalesDB = Server.CreateObject("ADODB.Connection")
-
-
' Open data connection - Use this line to use Access
-
'cnnSalesDB.Open "DBQ=" & Server.MapPath("MyData.mdb") & ";" _
-
' & "Driver={Microsoft Access Driver (*.mdb)};", "admin", ""
-
-
' Open data connection - Our SQL Server code
-
cnnSalesDB.Open "Provider=SQLOLEDB;Data Source=10.2.1.214;" _
-
& "Initial Catalog=samples;Connect Timeout=15;" _
-
& "Network Library=dbmssocn;", "samples", "password"
-
-
' Build our query for select box 1
-
strSQL = "SELECT * FROM sample ORDER BY last_name;"
-
-
' Create and open recordset object using existing connection
-
Set rstSalesmen = Server.CreateObject("ADODB.Recordset")
-
rstSalesmen.Open strSQL, cnnSalesDB, adOpenForwardOnly, adLockOptimistic, adCmdText
-
-
' Build our drop down box of salesmen names
-
If Not rstSalesmen.EOF Then
-
rstSalesmen.MoveFirst
-
%>
-
<select name="id">
-
<option></option>
-
<% ' Loop through names
-
Do While Not rstSalesmen.EOF
-
Response.Write "<option value="""
-
Response.Write rstSalesmen.Fields("id")
-
Response.Write """"
-
If rstSalesmen.Fields("id") = CInt(iRequestedID) Then
-
Response.Write "selected=""true"""
-
End If
-
Response.Write ">"
-
Response.Write Trim(rstSalesmen.Fields("first_name"))
-
Response.Write " "
-
Response.Write Trim(rstSalesmen.Fields("last_name"))
-
Response.Write "</option>" & vbCrLf
-
-
' Move to next record
-
rstSalesmen.MoveNext
-
Loop
-
%>
-
</select>
-
<%
-
End If
-
-
' Close ADO objects we're finished with and free DB variables
-
rstSalesmen.Close
-
Set rstSalesmen = Nothing
-
-
' If a request for a specific id comes in, then build second select box
-
If iRequestedID <> 0 Then
-
strSQL = "SELECT * FROM sales WHERE SalesmanId = " _
-
& iRequestedID & " ORDER BY timestamp"
-
-
Set rstSales = Server.CreateObject("ADODB.Recordset")
-
rstSales.Open strSQL, cnnSalesDB, adOpenForwardOnly, adLockOptimistic, adCmdText
-
-
' Build our drop down box of the salesmen's sales
-
If Not rstSales.EOF Then
-
rstSales.MoveFirst
-
%>
-
<select name="sale">
-
<option></option>
-
<% ' Loop through names
-
Do While Not rstSales.EOF
-
Response.Write "<option>$"
-
Response.Write Trim(rstSales.Fields("amount"))
-
Response.Write " on "
-
Response.Write Trim(rstSales.Fields("timestamp"))
-
Response.Write "</option>" & vbCrLf
-
-
' Move to next record
-
rstSales.MoveNext
-
Loop
-
%>
-
</select>
-
<%
-
End If
-
-
' Close ADO objects we're finished with and free DB variables
-
rstSales.Close
-
Set rstSales = Nothing
-
End If
-
-
' Close ADO objects we're finished with and free DB variables
-
cnnSalesDB.Close
-
Set cnnSalesDB = Nothing
-
%>
-
<input type="submit" value="Submit" />
-
</form>
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sherwood Botsford |
last post by:
Table Markers
ID (Primary Key)
This&That
PointClass (Combo box)
Points
Table PointClasses
PointClass (primary key)
Points (number)
Description (Text)
|
by: Tom G |
last post by:
Hello,
I need some advice on which way to resolve the following. On a form, the
user will make a selection from a combo box, after the selection several
different fields need to be updated on the form, based on the selection in
the combo box.
I have been doing this quite successfully by having the combo box rowsource
query contain all the fields and simply use the correct column to fill in
the text boxes. e.g. me.txtState =...
|
by: Antoine Janssen |
last post by:
hi,
I would like to create two combo boxes. In the first one you can select
a user in the second one you can select a project. To simplify the
selection i would like to shorten the project list by just presenting
the projects the selected user is working on (using a where clause with
the userid filled in). Does onyone know how to achieve this?
Kind Regards,
|
by: meganrobertson22 |
last post by:
Hi Everyone-
I have a question about how to add and then use the "All" selection in
a combo box. I am trying to figure out how to:
(1) add "All" as a selection to a combo box and then
(2) how to use the selection "All" as criteria for a field in a
query, which is used to generate data for a report.
|
by: Birderman |
last post by:
Hi
is it possible to enter data into two separate fields from a single combo
box selection.
ie if select entry in combo, field 1 will be filled with data from column 1
of combo and field2 will be filled with data from column 2 of the combo.
Anyhelp would be appreciated
Regards
| |
by: Magnus |
last post by:
Im using a set combobox (ComboBox1) to provide a selection of records from a
database table. I have a typed dataset (DataSet1) that contains the typed
datatable (DataTable1) that the combobox is bound to. The datatable in the
dataset is filled using the typed tableadapter (TableAdapter1). DataTable
consists of the typical primary key and value fields.
Here is the designer generated code for ComboBox1:
this.ComboBox1.DataSource =...
|
by: peasedm |
last post by:
Okay this one has me stumped. I have a table called Review_Statements
with the following columns:
statementid
type
statement1
statement2
statement3
I have a form called SR_Review with an unbound combo box control
|
by: pctec |
last post by:
Hello,
I have a combo box that is looking into a field from a table named Machines, this machine table has two columns; MachineName and MachineRate but the Combo Box it only showing the MachineName field.
What I want is to fill a different table with the MachineRate as soon as I select the MachineName. I’m already storing the MachineName with the Combo Box to table1 but need to extract automatically the MachineRate into a table1 as I select...
|
by: dudeja.rajat |
last post by:
On Sat, Aug 30, 2008 at 2:32 PM, Fredrik Lundh <fredrik@pythonware.comwrote:
Fredrik, Thanks so much. That worked.
Following this, I can now see that my combo2 has no previous elements
and contains only the elements relevant to selection in combo1.
Now, as soon as I select something in combo 2 and go back to change
selection in combo1 the combo2 must get its history cleared up (i.e
the previous selection in combo2's entry subwidget)
|
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...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |