Drawing a <SELECT> list filled with Access data CLIENTside ?

  • Thread starter Phil Di Guillielmo
  • Start date
P

Phil Di Guillielmo

Hi,
on CLIENT side, not with ASP (serverside) but with VBscript I would like to
fill and draw a SELECT LIST or COMBO BOX with data out of an Access table. I
just do not know how to do this ...

I use this combo with an Office Webcomponent Chart, also with data out of
Access or ODBC.
That last part is OK, out of the Examples of the Web Components, but they
only show select lists with standard fixed values, not dynamicly....
That's my problem.

PHIL
 
B

Bob Barrows

Phil said:
Hi,
on CLIENT side, not with ASP (serverside) but with VBscript I would
like to fill and draw a SELECT LIST or COMBO BOX with data out of an
Access table. I just do not know how to do this ...

You will need server-side code.
I use this combo with an Office Webcomponent Chart, also with data
out of Access or ODBC.
That last part is OK, out of the Examples of the Web Components, but
they only show select lists with standard fixed values, not
dynamicly....
That's my problem.

PHIL

If you truly need dynamic data (i.e., the options in the combo need to
change in response to user activity) then see my dynamic listbox example
which can be found here:
http://www.thrasherwebdesign.com/index.asp?pi=links&hp=links.asp&c=&a=clear
for one way to do it.

If the combo only has to be loaded once, simply use server-side code to
write the option elements into the client (this is air code - you will need
to add dim statements, error-handling, etc)::

<%
'open a recordset containing the option values (assuming the
'first column contains the value, and the second contains the
'text), then
if not rs.eof then
ar=rs.getrows
end if
rs.close:set rs=nothing
'close and destroy the connection as well
if isarray(ar) then
for i=0 to ubound(ar,2)
if len(sOptions) = 0 then
sOptions="<option value=""" & ar(0,i) & _
""">" & ar(1,i) & "</option>"
else
sOptions=sOptions & "<option value=""" & ar(0,i) & _
""">" & ar(1,i) & "</option>"
end if
next
else
sOptions= "<option value=""0"">No records</option>"
end if
%>
<HTML><body>
....
<SELECT>
<%=sOptions%>
</SELECT>

HTH,
Bob Barrows
 
M

mayayana

I'm not sure if this is what you want. It's code to put a
SELECT on the page and then add items to it
dynamically.

HTML:
<!-- SIZE value is number of rows to display. -->
<SELECT ID="List1" SIZE=10>
</SELECT>

Script:

to clear box:
List1.length = 0

to fill box, where ItemList is array of items to add, you need
to create an OPTION object for each item and then add it
to the SELECT:

Dim ObOption, i

For i = 0 to UBound(ItemList)
Set ObOption = document.createElement("OPTION")
ObOption.text = ItemList(i)
<!-- ObOption.value = ... optional way to add a
second value to list -->
List1.add ObOption
Set ObOption = Nothing
Next
 
P

Phil Di Guillielmo

mayayana said:
I'm not sure if this is what you want. It's code to put a
SELECT on the page and then add items to it
dynamically.
....

Hi
After a long test we solved the problem with an ADO control, and clientside
code (VBScript)

strDBQ = "Data Source=\\server01\dir1\Indicator.MDB;"
strProvider = "Provider=Microsoft.Jet.OLEDB.4.0; " & strDBQ
ADOConnection1.Open strProvider
Set rs = ADOConnection1.Execute("SELECT IdR, RubName FROM Rub ")

document.write("<SELECT id=lstRub size=10>")
rs.MoveFirst
counter = 1
Do While Not rs.EOF
if trim(counter) = trim(rubnr) then
document.write("<OPTION value=" & rs("IdR") & " selected >" &
rs("RubName ") & "</OPTION>")
else
document.write("<OPTION value=" & rs("IdR") & ">" & rs("RubName ")
& "</OPTION>")
end if
rs.MoveNext
counter = counter + 1
Loop
document.write("</SELECT>")
rs.Close

Filip
http://users.tijd.com/fiwi
 
B

Bob Barrows

Phil said:
Hi
After a long test we solved the problem with an ADO control, and
clientside code (VBScript)

strDBQ = "Data Source=\\server01\dir1\Indicator.MDB;"
strProvider = "Provider=Microsoft.Jet.OLEDB.4.0; " & strDBQ
ADOConnection1.Open strProvider
Set rs = ADOConnection1.Execute("SELECT IdR, RubName FROM Rub
")

document.write("<SELECT id=lstRub size=10>")
rs.MoveFirst
counter = 1
Do While Not rs.EOF
if trim(counter) = trim(rubnr) then
document.write("<OPTION value=" & rs("IdR") & " selected >" &
rs("RubName ") & "</OPTION>")
else
document.write("<OPTION value=" & rs("IdR") & ">" &
rs("RubName ") & "</OPTION>")
end if
rs.MoveNext
counter = counter + 1
Loop
document.write("</SELECT>")
rs.Close

Good luck. I hope you don't have to support a wide range of browsers and
operating systems.

I have had problems using client-side ADO even in an intranet environment
where we were enforcing the use of IE. Every so often we would encounter a
client machine where the ADO code would not work. In many cases, advising
the users to upgrade their MDAC installations solved the problem. But in a
couple cases (notably on Win2000 amd XP machines) the upgrade solution did
not work. The users were required to reinstall the operating system.

I have avoided using ADO on the client ever since.

Bob Barrows
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top