...

View Full Version : using javascript to autofill menu??



mikebyrne
12-15-2007, 05:01 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
strSQL = "SELECT PNUMBER, PNAME, PLOCATION, DNUM FROM Project"
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
objRS.MoveNext
Loop
Else
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

objRS.Close
End Sub
%>
<html>
<head>
<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 ;
else
return false ;
}
//-->
</script>
<style type="text/css">
<!--
.style1 {
font-size: 10mm;
font-weight: bold;
}
-->
</style>
</head>
<head>
<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="">
<label>
<div align="center">
<select name="Menuoption" size="1" id="Menuoption">
</select>
</div>
</label>
</form>
<form action="" method="post" name="" id="">
<label>
<div align="center">
<input type="submit" name="Add User" id="Add User" value="Add User">
</div>
</label>
</form>
<div align="center">
<table width="600" border="1" cellspacing="2" cellpadding="0">
<tr>
<td><b>Project Number</b></td>
<td><b>Project Name</b></td>
<td><b>Project Location</b></td>
<td><b>Department Number</b></td>
<td><b>Action</b></td>
</tr>
<% Call showProjects %>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
</table>
</p>
</div>
</body>
</html>

shyam
12-16-2007, 09:01 AM
yes its possible. fill up the options in the select and add the javascript to show/hide appropriate table rows



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum