|
 |
access_asp thread: Dynamic List Box
Message #1 by "Dale James Wright" <dwright@c...> on Thu, 9 Jan 2003 17:40:49
|
|
Hey guys,.,,,
I have a list box that is populated by a database table.... The users
selects their choice from the list, clicks on the forms submit button and
the information posted to the same page..... I then have code that picks
up the ID of the record selected and i use this ID to get records using
SQL... ie
"SELECT * FROM bla bla Where Blah Blah = " & id & ""
Ok..... Right this works fine, but is it possible to also get the ID and
the value selected.... For instance, if a user selects FOOTBALL with and
ID of 1.... I want to be able to "grab" the value 1 and the Name
FOOTBALL.... I have tried using hidden fields etc etc, but i cant figure
it out.... i am having a mind block today.... I cant seem to think
straight....
Thanks for your help guys....
Regards
ASP beginner.....
Dale
Message #2 by "Dale James Wright" <dwright@c...> on Thu, 9 Jan 2003 17:45:54
|
|
Sorry i forgot to post the code that is getting on my nerves (ps this is
just the dynamic list box code.)
Dim oRs1
Set Ors1=Server.CreateObject("ADODB.Recordset")
SQLtxt1 = "SELECT * FROM FAQDepartments"
ors1.Open sqltxt1, "DSN=BTContact", adopenforwardonly
oRs1.MoveFirst
%>
<select name="Department" style="font-family: Verdana,Arial,Helvetica,sans-
serif; font-size:12px; background-color: rgb(240,240,240); color: rgb
(0,0,0)">
<%
Do While Not oRS1.EOF
Response.Write "<option value=" & ors1("Record_Number") & ">"
oRs1.MoveNext
Loop
ors1.Close
set ors1 = Nothing
Message #3 by "anjali" <microfredo@m...> on Fri, 10 Jan 2003 12:12:03 -0700
|
|
Try This
set RSBooks = strConnect.Execute("select ID_Num,First_Name,Last_Name from
India")
Do Until RSBooks.Eof
BookOptions = BookOptions & "<OPTION VALUE=""" & RSBooks(ID_Num") & """>" _
RSBooks("First_Name") & " " & RSBooks("Last_Name") & "</OPTION>"
RSBooks.MoveNext
Loop
It works for me. The ID number is not shown but the First and last name is.
anjali
----- Original Message -----
From: "Dale James Wright" <dwright@c...>
To: "Access ASP" <access_asp@p...>
Sent: Thursday, January 09, 2003 5:40 PM
Subject: [access_asp] Dynamic List Box
> Hey guys,.,,,
>
> I have a list box that is populated by a database table.... The users
> selects their choice from the list, clicks on the forms submit button and
> the information posted to the same page..... I then have code that picks
> up the ID of the record selected and i use this ID to get records using
> SQL... ie
>
> "SELECT * FROM bla bla Where Blah Blah = " & id & ""
>
> Ok..... Right this works fine, but is it possible to also get the ID and
> the value selected.... For instance, if a user selects FOOTBALL with and
> ID of 1.... I want to be able to "grab" the value 1 and the Name
> FOOTBALL.... I have tried using hidden fields etc etc, but i cant figure
> it out.... i am having a mind block today.... I cant seem to think
> straight....
>
> Thanks for your help guys....
>
> Regards
>
> ASP beginner.....
>
> Dale
>
|
|
 |