|
 |
asp_web_howto thread: Combo Boxes from a database in Netscape
Message #1 by Jay Franklin <jayrfranklin@y...> on Mon, 22 Jan 2001 05:35:38 -0800 (PST)
|
|
To all my fellow ASPers,
I am building a Web Site which pulls my combo box data
from a SQL server database. Does anyone know how I
can get this to work in Netscape?
Thanks
Jay Franklin
Rosslyn, VA
Message #2 by Gregory_Griffiths@c... on Mon, 22 Jan 2001 13:53:01 +0000
|
|
Use standard HTML tags ? IE is known to be more leniant on bad syntax
and also has a lot of custom "IE-only" tags as well, once you have
sorted this out it should work in both. Post a URL and we'll take a
look.
> -----Original Message-----
> From: jayrfranklin@y... [mailto:jayrfranklin@y...]
> Sent: 22 January 2001 21:55
> To: asp_web_howto@p...
> Cc: jayrfranklin@y...
> Subject: [asp_web_howto] Combo Boxes from a database in Netscape
>
>
> To all my fellow ASPers,
>
> I am building a Web Site which pulls my combo box data
> from a SQL server database. Does anyone know how I
> can get this to work in Netscape?
>
> Thanks
>
> Jay Franklin
> Rosslyn, VA
>
>
Message #3 by Imar Spaanjaars <Imar@S...> on Mon, 22 Jan 2001 14:58:29 +0100
|
|
You mean Netscape as in the browser?? In that case, the code should be the
same as for any other browser since ASP is running server side and sending
plain ol' HTML to the browser.
If I take a wild guess (hard to do without seeing your code) I think you
forgot to surround the SELECT item by the <FORM> tag. Netscape doesn't
display any controls if they are not placed inside a <FORM> container.
If this is not the problem, here is a short (untested) example on how to do it:
sub showMyList()
Response.Write("<SELECT ID=""lstMySelectList""
NAME=""lstMySelectList"">" & vbCRLF)
Dim sSQL
Dim rsFillSelect
sSQL = "Select ID, Description FROM tblMyTable ORDER BY Description"
Set rsFillSelect = Server.CreateObject("ADODB.recordset")
With rsFillSelect
.Open sSQL, sMyConnectionStringOrObject,
adOpenForwardOnly, adLockReadOnly, adCmdText
if not .EOF then ' Records exist
do while not .EOF
Response.Write(vbTAB & "<OPTION VALUE="""
& .Fields.Item(0) & """>" & .Fields.Item(1) & "</option>" & vbCRLF)
.MoveNext()
loop
end if
.Close()
End with
Set rsFillSelect = nothing
Response.Write("</select>")
end sub
This sub uses the MoveNext method to loop through the recordset. This is
not the fastest way to do these things. A better method would be to use the
GetRows() method of the recordset object.
GetRows() will return a two-dimensional array with the contents of the
recordset. By determining the UBound of the array you can loop through it,
writing out your OPTION elements.
HtH
Imar
At 01:55 PM 1/22/2001 -0800, you wrote:
>To all my fellow ASPers,
>
>I am building a Web Site which pulls my combo box data
>from a SQL server database. Does anyone know how I
>can get this to work in Netscape?
>
>Thanks
>
>Jay Franklin
>Rosslyn, VA
|
|
 |