View Full Version : Auto fill menu from db??

12-15-2007, 03:57 PM
Is it possible to autofill my menu with the pnum fields and depending on the user selection show the table below.

At the moment my table just displays all records

<!-- #include file="connection.asp" -->
' Dim variables
Dim strSQL, objRS

Sub showProjects
Set objRS = siteConn.Execute(strSQL)

If Not objRS.EOF Then
Do While Not objRS.EOF
response.write Space(4) & "<tr>" & vbCrLf
response.write Space(6) & "<td>" & objRS("PNUMBER") & "</td>" & vbCrLf
response.write Space(6) & "<td>" & objRS("PNAME") & "</td>" & vbCrLf
response.write Space(6) & "<td>" & objRS("PLOCATION") & "</td>" & vbCrLf
response.write Space(6) & "<td>" & objRS("DNUM") & "</td>" & vbCrLf
response.write Space(6) & "<td><a href=""editProject.asp?pNumber=" & objRS("PNUMBER") & """>Edit</a> | <a href=""deleteProject.asp?pNumber=" & objRS("PNUMBER") & """ onclick=""return confirmDelete()"">Delete</a></td>" & vbCrLf
response.write Space(4) & "</tr>" & vbCrLf
response.write Space(4) & "<tr>" & vbCrLf
response.write Space(6) & "<td colspan=""5"">Sorry, currently no available projects.</td>" & vbCrLf
response.write Space(4) & "</tr>" & vbCrLf
End If

End Sub
<script type="text/javascript">
<!-- Hide the script from old browsers --
function confirmDelete() {
var deleteRecord = confirm("Are you sure you want to delete this record?");
if (deleteRecord)
return true ;
return false ;
<style type="text/css">
.style1 {
font-size: 10mm;
font-weight: bold;
<title>Displaying Records: Projects Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body bgcolor="#FFFF00">
<p align="center" class="style1">Database Maintenance System
<p align="center">Please select project number from the menu or Add new project button:</p>
<form name="form1" method="post" action="">
<div align="center">
<select name="Menuoption" size="1" id="Menuoption">
<form action="" method="post" name="" id="">
<div align="center">
<input type="submit" name="Add User" id="Add User" value="Add User">
<div align="center">
<table width="600" border="1" cellspacing="2" cellpadding="0">
<td><b>Project Number</b></td>
<td><b>Project Name</b></td>
<td><b>Project Location</b></td>
<td><b>Department Number</b></td>
<% Call showProjects %>
<td colspan="4">&nbsp;</td>

12-23-2007, 02:24 PM
Here are 2 possible solutions:

Accept the user's selection as a postback and then redirect to a new page to display the table.
Use AJAX to dynamically rebuild the table. Basically you would need some JavaScript to handle the user's selection. It would build a new XMLHttpRequest object, call the send method for another page. This page would return the table and the JavaScript code in your original page would use the response to rebuild the table.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum