Display User Selection From Combo Box

R

rikesh

Hi

I'm sure this is a very trivial problem!
I have a combo bound to a recordset. I was wondering how I can show the
value on the page, what the user has selected?
The code that I'm using is below.
Any help, would be much apprceciated.

Kind regards

--
Kind Regards

Rikesh
(V.InterDev6.0-SP5/W2K-SP4/SQL2K-SP3)



<%

Dim objConnection 'The connection object
Dim objRecordset 'The recordset object

' create the Connection object
Set objConnection = Server.CreateObject("ADODB.Connection")
' open the DSN
objConnection.Open "Provider=sqloledb;" & _
"Data Source=DEVSVR;" & _
"Initial Catalog=pubs;" & _
"User Id=sa;" & _
"Password=admin"

' creates the recordset object
Set objRecordset = Server.CreateObject("ADODB.Recordset")

' SQL String for query
Dim strSQL
strSQL = "SELECT au_id, au_lname FROM Authors"

' execute the SQL statement that you want
' The query should return all the data you'll
' need in your combo box
objRecordset.Open strSQL, objConnection

Request.Form("au_lname")
Response.Write (Request.Form("au_lname"))

%>
<HTML>
<BODY>
<FORM ACTION="DBCombo.asp" METHOD=POST>
<select name=cboPrimary size=1 >
<!--onChange="frmTest.submit();"> -->
Choose from the combo:
select name="lstTopic" size="1">
<%
' while we don't get the end of DataBase
Do While Not objRecordset.EOF
'we put the ID at Value
'this value is important to linked tables
%>
<option VALUE="<%=objRecordset("au_ID")%>">
<!-- This is what will appear in the combo box -->
<%=objRecordset("au_lname")%>
</option>
<%
' Move to the next record...
objRecordset.MoveNext
Loop ' keep the loop
%>
</SELECT>
</FORM>
</BODY>
</HTML>
<%
' close the recordset object
objRecordset.Close

' clean the Recordset object
Set objRecordset = Nothing
%>
 
A

Alex Goodey

Do you want to the selection to be displayed on the same page as the form?
or after the fgorm has been submitted?

if it's the first then it is a client side issue and you will have a better
response from a client side or javascript newsgroup
 
A

Alex Goodey

yep, do a search on google and you will probably find what you are looking
for.

it will be something to do with the onChange event of the drop down, or
something like that
 
±

±Ç¹Î¼ö

rikesh said:
Hi

I'm sure this is a very trivial problem!
I have a combo bound to a recordset. I was wondering how I can show the
value on the page, what the user has selected?
The code that I'm using is below.
Any help, would be much apprceciated.

Kind regards

--
Kind Regards

Rikesh
(V.InterDev6.0-SP5/W2K-SP4/SQL2K-SP3)



<%

Dim objConnection 'The connection object
Dim objRecordset 'The recordset object

' create the Connection object
Set objConnection = Server.CreateObject("ADODB.Connection")
' open the DSN
objConnection.Open "Provider=sqloledb;" & _
"Data Source=DEVSVR;" & _
"Initial Catalog=pubs;" & _
"User Id=sa;" & _
"Password=admin"

' creates the recordset object
Set objRecordset = Server.CreateObject("ADODB.Recordset")

' SQL String for query
Dim strSQL
strSQL = "SELECT au_id, au_lname FROM Authors"

' execute the SQL statement that you want
' The query should return all the data you'll
' need in your combo box
objRecordset.Open strSQL, objConnection

Request.Form("au_lname")
Response.Write (Request.Form("au_lname"))

%>
<HTML>
<BODY>
<FORM ACTION="DBCombo.asp" METHOD=POST>
<select name=cboPrimary size=1 >
<!--onChange="frmTest.submit();"> -->
Choose from the combo:
select name="lstTopic" size="1">
<%
' while we don't get the end of DataBase
Do While Not objRecordset.EOF
'we put the ID at Value
'this value is important to linked tables
%>
<option VALUE="<%=objRecordset("au_ID")%>">
<!-- This is what will appear in the combo box -->
<%=objRecordset("au_lname")%>
</option>
<%
' Move to the next record...
objRecordset.MoveNext
Loop ' keep the loop
%>
</SELECT>
</FORM>
</BODY>
</HTML>
<%
' close the recordset object
objRecordset.Close

' clean the Recordset object
Set objRecordset = Nothing
%>


<script language="javascript">
<!--
function ChangeSelect(which)
{
var wOne = which

document.sel.chgsel.value = wOne;
}
//-->
</script>
</HEAD>

<form name="sel">
<select name="lect" OnChange="ChangeSelect(this.value);">
<option value="111">111</option>
<option value="222">222</option>
<option value="333">333</option>
<option value="444">444</option>
<option value="555">555</option>
</select>
<br><br>
<input type="text" name="chgsel" size="20">
</form>


MSN : (e-mail address removed)
email : (e-mail address removed)
http://www.ubizcom.co.kr
---------------------------------------------- From DevSonner
 
R

rikesh

Cheers that works really well, by the way, a quick question, can one use
javascript and VBScript on the same page???
 
M

middletree

hate to soudn like one of those people who always corrects others, but it's
not a combo. Call it a select, or a dropdown, or whatever you want. But
there is no such thing as a combo on web products.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top