Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2007
    Posts
    48
    Thanks
    5
    Thanked 0 Times in 0 Posts

    using javascript to autofill menu??

    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

    Code:
    <!-- #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>

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    yes its possible. fill up the options in the select and add the javascript to show/hide appropriate table rows
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •