General discussion

Locked

ASP/Access Update Table by DropDown Menu

By jlindemann ·
I'm a bit of a newbie when it comes to using a database with a webpage. It is important that I use MSAccess for this.

I'm trying to create a business directory that will show results depending on what is chosen in the category list.
Inside this database I have a table which holds these fields: Category - Business - Address - Phone - Fax.
On my webpage I have a drop-down menu that will hold a list of each one of the Category items in it. When I select an item from the Category list I want my table to give me all the businesses in that selected category. (just as a side note, my table is created as a "Repeated - Server Behaviour" item with the items of database.business - database.address - database.phone - database.fax) Problem is, how do I do this? Everywhere I look I keep finding ways to "auto-populate" my drop-down list. But that's not what i want to do. What I want is to populate my table according what the drop-down list item that is chosen. Can you help point me out how to do it?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

by unwanted_email In reply to ASP/Access Update Table b ...

Hi

I've created a working example of how I would go about it. Email me at unwanted_email@hotmail.com if you would like a zipped copy of it. Below is the code I used. Regards Darren.


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
'Connect to db
Set db = Server.CreateObject("ADODB.Connection")
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data source="& Server.MapPath("database.mdb")
db.Open strconn

'Set Recordsets
dim category
if request.QueryString("category")<>"" then
category = request.QueryString("category")
Set rsfilter = db.Execute("SELECT * FROM tblContacts WHERE Category='" & category & "'")
else
category = "All Categories"
Set rsfilter = db.Execute("SELECT * FROM tblContacts")
end if
Set rsdistinct = db.Execute("SELECT DISTINCT Category FROM tblContacts ORDER BY Category ASC")
%>

<html>
<head>
<title>Example</title>
</head>
<body>
<form method="get" action="example.asp">
<select name="category">
<option value="">All Categories</option>
<%
'Create the select box options from all the unique categories in the recordset
do until rsdistinct.eof
%>
<option><% response.Write(rsdistinct("Category")) %></option>
<%
rsdistinct.movenext
loop
%>
</select>
 
<input type="submit" value="Go">
<br>
<table cellspacing="2" cellpadding="1" width="750" align="left" border="1">
<tr>
<td width="100%" align="center" colspan="4"><b>Category:</b> <%Response.Write(category)%></td>
</tr>
<tr>
<td width="25%"><b>Business</b></td>
<td width="25%"><b>Address</b></td>
<td width="25%"><b>Phone</b></td>
<td width="25%"><b>Fax</b></td>
</tr>
<%
do until rsfilter.eof
%>
<tr>
<td width="25%"><%response.Write(rsfilter("Business"))%></td>
<td width="25%"><%response.Write(rsfilter("Address"))%></td>
<td width="25%"><%response.Write(rsfilter("Phone"))%></td>
<td width="25%"><%response.Write(rsfilter("Fax"))%></td>
</tr>
<%
rsfilter.movenext
loop
%>
</table>
</form>
</body>
<%
db.Close
Set db = Nothing
%>
</html>

Collapse -

by jlindemann In reply to

This didn't help me, and it's been decided that we move towards PHP\mySQL where it can be done easier

Collapse -

by jlindemann In reply to ASP/Access Update Table b ...

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums