UBigDummie
08-19-2006, 10:53 PM
Hey Guys.
Can someone please tell me what is wrong with my code? I have an alphabet and non-alphabet list which is broken down by each letter. Each letter should be a link. Example of the link (vendorList.asp?startletter=B). The nonalphabet works perfect (the link is correct in the URL and it pulls my info from the Access DB), but the letters truncate the letter in the URL. If I actually type the letter on the end of the URL, it works and pulls the info from the DB, but the actual link on the page omits the letter so it would look like this (vendorList.asp?startletter=). I'll post my code just in case someone can help me. Thanks.
Andy
------------
<%
Option Explicit
Dim sql,rsVendors,rsVendor,startletter,alphabet,companyName,contactName,phone
startletter = Request.QueryString ("startletter")
if startletter = "" then
startletter = "A"
end if
%>
<!--#include file="conn.asp"-->
<%
if startletter = "nonalphabet" then
sql = "SELECT companyName, contactName, phone, extension FROM vendors WHERE companyName Not Like 'a%'"
for alphabet = 98 to 122
sql = sql & "AND companyName Not Like '" & chr(alphabet) & "%'"
next
sql = sql & " ORDER BY companyName"
else
sql = "SELECT companyName, contactName, phone, extension FROM vendors WHERE companyName Like '" & startletter & "%' ORDER BY companyName"
end if
Set rsVendors = Server.CreateObject ("ADODB.Recordset")
rsVendors.Open sql, conn, 3, 3
sql ="SELECT phone, contactName, extension FROM vendors WHERE companyName = '" & companyName & "'"
Set rsVendor = Server.CreateObject ("ADODB.Recordset")
rsVendor.Open sql, conn, 3, 3
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Purchasing | Control Panel</title>
<link rel="stylesheet" href="emx_nav_left.css" type="text/css" />
<script type="text/javascript">
<!--
var time = 3000;
var numofitems = 7;
//menu constructor
function menu(allitems,thisitem,startstate){
callname= "gl"+thisitem;
divname="subglobal"+thisitem;
this.numberofmenuitems = allitems;
this.caller = document.getElementById(callname);
this.thediv = document.getElementById(divname);
this.thediv.style.visibility = startstate;
}
//menu methods
function ehandler(event,theobj){
for (var i=1; i<= theobj.numberofmenuitems; i++){
var shutdiv =eval( "menuitem"+i+".thediv");
shutdiv.style.visibility="hidden";
}
theobj.thediv.style.visibility="visible";
}
function closesubnav(event){
if ((event.clientY <48)||(event.clientY > 107)){
for (var i=1; i<= numofitems; i++){
var shutdiv =eval('menuitem'+i+'.thediv');
shutdiv.style.visibility='hidden';
}
}
}
// -->
</script>
</head>
<body onmousemove="closesubnav(event);">
<div class="skipLinks">skip to: <a href="#content">page content</a> | <a href="#pageNav">links on this page</a> | <a href="#globalNav">site navigation</a> | <a href="#siteInfo">footer (site information)</a> </div>
<div id="masthead">
<h1 id="siteName">Purchasing | Control Panel </h1>
<div id="utility"> <a href="#">Home</a> | <a href="#">Rolodex</a> | <a href="#">Purchase Orders</a> </div>
<div id="globalNav"> <img alt="" src="gblnav_left.gif" height="32" width="4" id="gnl" /> <img alt="" src="glbnav_right.gif" height="32" width="4" id="gnr" />
<div id="globalLink"> <a href="#" id="gl1" class="glink" onmouseover="ehandler(event,menuitem1);">Home</a><a href="#" id="gl2" class="glink" onmouseover="ehandler(event,menuitem2);">Vendors</a><a href="#" id="gl3" class="glink" onmouseover="ehandler(event,menuitem3);">Departments</a><a href="#" id="gl4" class="glink" onmouseover="ehandler(event,menuitem4);">Products</a><a href="#" id="gl5" class="glink" onmouseover="ehandler(event,menuitem5);">Purchase Orders</a><a href="#" id="gl6" class="glink" onmouseover="ehandler(event,menuitem6);">Quotes</a><a href="#" id="gl7" class="glink" onmouseover="ehandler(event,menuitem7);">Messages</a> </div>
<!--end globalLinks-->
<form id="search" action="">
<input name="searchFor" type="text" size="10" />
<a href="">search</a>
</form>
</div>
<!-- end globalNav -->
<div id="subglobal1" class="subglobalNav"> <a href="default.asp">Home</a> </div>
<div id="subglobal2" class="subglobalNav"> <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> </div>
<div id="subglobal3" class="subglobalNav"> <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> </div>
<div id="subglobal4" class="subglobalNav"> <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> </div>
<div id="subglobal5" class="subglobalNav"> <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> </div>
<div id="subglobal6" class="subglobalNav"> <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> </div>
<div id="subglobal7" class="subglobalNav"> <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> </div>
<div id="subglobal8" class="subglobalNav"> <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> </div>
</div>
<!-- end masthead -->
<div id="pagecell1">
<!--pagecell1-->
<img alt="" src="tl_curve_white.gif" height="6" width="6" id="tl" /> <img alt="" src="tr_curve_white.gif" height="6" width="6" id="tr" />
<div id="breadCrumb"> <a href="#">Home</a> / <a href="#">Vendors</a> / Purchase Orders /</div>
<div id="pageName">
<h2>Purchasing </h2>
</div>
<div id="pageNav">
<div id="sectionLinks"> <a href="#">Vendors</a> <a href="#">Departments</a> <a href="#">Products</a> <a href="#">Purchase Orders </a> <a href="#">Quotes</a> <a href="#">Messages</a> <a href="#">Reminders</a> <a href="#">To Do List</a> </div>
<div class="relatedLinks">
<h3>Listing By Department </h3>
<a href="#">Final Finish </a> <a href="#">Interior</a> <a href="#">Exterior</a> <a href="#">Plumbing</a> <a href="#">Electrical</a> <a href="#">Other Departments</a> </div>
<div class="relatedLinks">
<h3>Purchasing Tools</h3>
<a href="#">Inventory Counts</a> <a href="#">Production Projections</a> <a href="#">*</a> <a href="#">*</a> <a href="#">*</a> <a href="#">*</a> </div>
<div id="advert">
<img src="wow2.gif" alt="Keep Smiling" width="32" height="32" />
</div>
</div>
<div id="content">
<div class="feature">
<h3>Vendor Rolodex</h3>
<table cellpadding="2" cellspaceing="0" border="1" bordercolor="#B4B4B4" width="100%">
<tr>
<td align="center" bgcolor="#FFFFFF"><b><a href="vendorList.asp?startletter=nonalphabet">123</a></b>
<%
for alphabet = 65 to 90
%>
<td align="center" bgcolor="#FFFFFF"><b><a href="vendorList.asp?startletter=<%chr(alphabet)%>"><%=chr(alphabet)%></a></b></td>
<%next%>
</tr>
</table>
<%if not rsVendors.EOF then%>
<table cellpadding="2" cellspacing="0" border="1" bordercolor="#B4B4B4" width="100%">
<tr bgcolor="B4B4B4">
<th width="30%">Company Name</th>
<th width="30%">Phone Number</th>
<th width="30%">Contact</th>
<th width="10%">Ext</th>
</tr>
<%rsVendors.Movefirst
do until rsVendors.EOF%>
<tr>
<td><%=rsVendors("companyName")%></td>
<td><%=rsVendors("phone")%></td>
<td><%=rsVendors("contactName")%></td>
<td><%=rsVendors("extension")%></td>
</tr>
<%rsVendors.Movenext
loop%>
</table>
<% ' If no users, give a message
else
%>
<p>Sorry, there are no vendors starting with the letter <%=startletter%>.</p>
<%end if%>
</div>
<div class="story"></div>
<div class="story">
</div>
</div>
<div id="siteInfo"> <img src="" width="44" height="22" /> <a href="#">About Us</a> | <a href="#">Site Map</a> | <a href="#">Privacy Policy</a> | <a href="#">Contact Us</a> | ©2006 </div>
</div>
<!--end pagecell1-->
<br />
<script type="text/javascript">
<!--
var menuitem1 = new menu(7,1,"hidden");
var menuitem2 = new menu(7,2,"hidden");
var menuitem3 = new menu(7,3,"hidden");
var menuitem4 = new menu(7,4,"hidden");
var menuitem5 = new menu(7,5,"hidden");
var menuitem6 = new menu(7,6,"hidden");
var menuitem7 = new menu(7,7,"hidden");
// -->
</script>
</body>
</html>
<%
rsVendors.close
set rsVendors = nothing
conn.close
set conn = nothing
%>
Can someone please tell me what is wrong with my code? I have an alphabet and non-alphabet list which is broken down by each letter. Each letter should be a link. Example of the link (vendorList.asp?startletter=B). The nonalphabet works perfect (the link is correct in the URL and it pulls my info from the Access DB), but the letters truncate the letter in the URL. If I actually type the letter on the end of the URL, it works and pulls the info from the DB, but the actual link on the page omits the letter so it would look like this (vendorList.asp?startletter=). I'll post my code just in case someone can help me. Thanks.
Andy
------------
<%
Option Explicit
Dim sql,rsVendors,rsVendor,startletter,alphabet,companyName,contactName,phone
startletter = Request.QueryString ("startletter")
if startletter = "" then
startletter = "A"
end if
%>
<!--#include file="conn.asp"-->
<%
if startletter = "nonalphabet" then
sql = "SELECT companyName, contactName, phone, extension FROM vendors WHERE companyName Not Like 'a%'"
for alphabet = 98 to 122
sql = sql & "AND companyName Not Like '" & chr(alphabet) & "%'"
next
sql = sql & " ORDER BY companyName"
else
sql = "SELECT companyName, contactName, phone, extension FROM vendors WHERE companyName Like '" & startletter & "%' ORDER BY companyName"
end if
Set rsVendors = Server.CreateObject ("ADODB.Recordset")
rsVendors.Open sql, conn, 3, 3
sql ="SELECT phone, contactName, extension FROM vendors WHERE companyName = '" & companyName & "'"
Set rsVendor = Server.CreateObject ("ADODB.Recordset")
rsVendor.Open sql, conn, 3, 3
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Purchasing | Control Panel</title>
<link rel="stylesheet" href="emx_nav_left.css" type="text/css" />
<script type="text/javascript">
<!--
var time = 3000;
var numofitems = 7;
//menu constructor
function menu(allitems,thisitem,startstate){
callname= "gl"+thisitem;
divname="subglobal"+thisitem;
this.numberofmenuitems = allitems;
this.caller = document.getElementById(callname);
this.thediv = document.getElementById(divname);
this.thediv.style.visibility = startstate;
}
//menu methods
function ehandler(event,theobj){
for (var i=1; i<= theobj.numberofmenuitems; i++){
var shutdiv =eval( "menuitem"+i+".thediv");
shutdiv.style.visibility="hidden";
}
theobj.thediv.style.visibility="visible";
}
function closesubnav(event){
if ((event.clientY <48)||(event.clientY > 107)){
for (var i=1; i<= numofitems; i++){
var shutdiv =eval('menuitem'+i+'.thediv');
shutdiv.style.visibility='hidden';
}
}
}
// -->
</script>
</head>
<body onmousemove="closesubnav(event);">
<div class="skipLinks">skip to: <a href="#content">page content</a> | <a href="#pageNav">links on this page</a> | <a href="#globalNav">site navigation</a> | <a href="#siteInfo">footer (site information)</a> </div>
<div id="masthead">
<h1 id="siteName">Purchasing | Control Panel </h1>
<div id="utility"> <a href="#">Home</a> | <a href="#">Rolodex</a> | <a href="#">Purchase Orders</a> </div>
<div id="globalNav"> <img alt="" src="gblnav_left.gif" height="32" width="4" id="gnl" /> <img alt="" src="glbnav_right.gif" height="32" width="4" id="gnr" />
<div id="globalLink"> <a href="#" id="gl1" class="glink" onmouseover="ehandler(event,menuitem1);">Home</a><a href="#" id="gl2" class="glink" onmouseover="ehandler(event,menuitem2);">Vendors</a><a href="#" id="gl3" class="glink" onmouseover="ehandler(event,menuitem3);">Departments</a><a href="#" id="gl4" class="glink" onmouseover="ehandler(event,menuitem4);">Products</a><a href="#" id="gl5" class="glink" onmouseover="ehandler(event,menuitem5);">Purchase Orders</a><a href="#" id="gl6" class="glink" onmouseover="ehandler(event,menuitem6);">Quotes</a><a href="#" id="gl7" class="glink" onmouseover="ehandler(event,menuitem7);">Messages</a> </div>
<!--end globalLinks-->
<form id="search" action="">
<input name="searchFor" type="text" size="10" />
<a href="">search</a>
</form>
</div>
<!-- end globalNav -->
<div id="subglobal1" class="subglobalNav"> <a href="default.asp">Home</a> </div>
<div id="subglobal2" class="subglobalNav"> <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> | <a href="#">subglobal2 link</a> </div>
<div id="subglobal3" class="subglobalNav"> <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> | <a href="#">subglobal3 link</a> </div>
<div id="subglobal4" class="subglobalNav"> <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> | <a href="#">subglobal4 link</a> </div>
<div id="subglobal5" class="subglobalNav"> <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> | <a href="#">subglobal5 link</a> </div>
<div id="subglobal6" class="subglobalNav"> <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> | <a href="#">subglobal6 link</a> </div>
<div id="subglobal7" class="subglobalNav"> <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> | <a href="#">subglobal7 link</a> </div>
<div id="subglobal8" class="subglobalNav"> <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> | <a href="#">subglobal8 link</a> </div>
</div>
<!-- end masthead -->
<div id="pagecell1">
<!--pagecell1-->
<img alt="" src="tl_curve_white.gif" height="6" width="6" id="tl" /> <img alt="" src="tr_curve_white.gif" height="6" width="6" id="tr" />
<div id="breadCrumb"> <a href="#">Home</a> / <a href="#">Vendors</a> / Purchase Orders /</div>
<div id="pageName">
<h2>Purchasing </h2>
</div>
<div id="pageNav">
<div id="sectionLinks"> <a href="#">Vendors</a> <a href="#">Departments</a> <a href="#">Products</a> <a href="#">Purchase Orders </a> <a href="#">Quotes</a> <a href="#">Messages</a> <a href="#">Reminders</a> <a href="#">To Do List</a> </div>
<div class="relatedLinks">
<h3>Listing By Department </h3>
<a href="#">Final Finish </a> <a href="#">Interior</a> <a href="#">Exterior</a> <a href="#">Plumbing</a> <a href="#">Electrical</a> <a href="#">Other Departments</a> </div>
<div class="relatedLinks">
<h3>Purchasing Tools</h3>
<a href="#">Inventory Counts</a> <a href="#">Production Projections</a> <a href="#">*</a> <a href="#">*</a> <a href="#">*</a> <a href="#">*</a> </div>
<div id="advert">
<img src="wow2.gif" alt="Keep Smiling" width="32" height="32" />
</div>
</div>
<div id="content">
<div class="feature">
<h3>Vendor Rolodex</h3>
<table cellpadding="2" cellspaceing="0" border="1" bordercolor="#B4B4B4" width="100%">
<tr>
<td align="center" bgcolor="#FFFFFF"><b><a href="vendorList.asp?startletter=nonalphabet">123</a></b>
<%
for alphabet = 65 to 90
%>
<td align="center" bgcolor="#FFFFFF"><b><a href="vendorList.asp?startletter=<%chr(alphabet)%>"><%=chr(alphabet)%></a></b></td>
<%next%>
</tr>
</table>
<%if not rsVendors.EOF then%>
<table cellpadding="2" cellspacing="0" border="1" bordercolor="#B4B4B4" width="100%">
<tr bgcolor="B4B4B4">
<th width="30%">Company Name</th>
<th width="30%">Phone Number</th>
<th width="30%">Contact</th>
<th width="10%">Ext</th>
</tr>
<%rsVendors.Movefirst
do until rsVendors.EOF%>
<tr>
<td><%=rsVendors("companyName")%></td>
<td><%=rsVendors("phone")%></td>
<td><%=rsVendors("contactName")%></td>
<td><%=rsVendors("extension")%></td>
</tr>
<%rsVendors.Movenext
loop%>
</table>
<% ' If no users, give a message
else
%>
<p>Sorry, there are no vendors starting with the letter <%=startletter%>.</p>
<%end if%>
</div>
<div class="story"></div>
<div class="story">
</div>
</div>
<div id="siteInfo"> <img src="" width="44" height="22" /> <a href="#">About Us</a> | <a href="#">Site Map</a> | <a href="#">Privacy Policy</a> | <a href="#">Contact Us</a> | ©2006 </div>
</div>
<!--end pagecell1-->
<br />
<script type="text/javascript">
<!--
var menuitem1 = new menu(7,1,"hidden");
var menuitem2 = new menu(7,2,"hidden");
var menuitem3 = new menu(7,3,"hidden");
var menuitem4 = new menu(7,4,"hidden");
var menuitem5 = new menu(7,5,"hidden");
var menuitem6 = new menu(7,6,"hidden");
var menuitem7 = new menu(7,7,"hidden");
// -->
</script>
</body>
</html>
<%
rsVendors.close
set rsVendors = nothing
conn.close
set conn = nothing
%>