pat18581
12-05-2005, 01:51 PM
I have an asp page that searchs a database and pages the results. the page runs and displays the results on the same page. but i would like the text on the page to not be shown when the results are shown. is there a way to do this.
BarrMan
12-05-2005, 02:06 PM
what text do you want to not be shown? if you want to do it in form you can do <input type="hidden" name="" value="value">.
but if you want something else to not be shown you can just not response.write it or w/e writes it.
pat18581
12-05-2005, 02:08 PM
It is in a html div at the bottom of the page not in the asp script. i want it to be displayed before the search is done and the invisible when the search results are displayed
BarrMan
12-05-2005, 02:22 PM
can you post the code plz?
i can't really understand what you're saying.
pat18581
12-05-2005, 02:31 PM
Heres the code:
<%
Option Explicit
'************************************************************************************
'* Declaration section
'************************************************************************************
' Mode contstants
Const MODE_DEFAULT = 1
Const MODE_RESULTS = 2
Const DB_NAME = "/db/iberianew1.mdb" ' Name of our database file
Const SCRIPT_NAME = "products.asp" ' Name of this script
Const RECORDS_PER_PAGE = 20 ' Number of records per page
Dim nMode ' Current Mode
'************************************************************************************
'* End of Declaration section
'************************************************************************************
'************************************************************************************
'* Main section
'************************************************************************************
' Find out what mode we are in
nMode = CLng(Request.QueryString("Mode"))
' Depending on our mode we will do different things
Select Case nMode
Case MODE_RESULTS
' This is where all the results will show
ShowResults
Case Else ' This one is for MODE_DEFAULT or invalid modes all the same
' By default display the search form
ShowSearchForm
End Select
'************************************************************************************
'* End of Main section
'************************************************************************************
'************************************************************************************
'* Functions section
'************************************************************************************
' This function will generate our connection string
' it assumes that Access database is in the same folder as this script
Private Function GetConnectionString()
GetConnectionString = "Driver={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath(DB_NAME) & ";" & _
"UID=;PWD=;"
End Function
' Shows HTML page header
Public Function OutputPageHeader()
%>
<%
Response.Buffer = True
%>
<html>
<head>
<title>Univar Iberia</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<SCRIPT LANGUAGE="JavaScript">
// This script is intended for use with a minimum of Netscape 4 or IE 4.
if(document.getElementById) {
var upLevel = true;
}
else if(document.layers) {
var ns4 = true;
}
else if(document.all) {
var ie4 = true;
}
function showObject(obj) {
if (ns4) obj.visibility = "show";
else if (ie4 || upLevel) obj.style.visibility = "visible";
}
function hideObject(obj) {
if (ns4) {
obj.visibility = "hide";
}
if (ie4 || upLevel) {
obj.style.visibility = "hidden";
}
}
</SCRIPT>
<link href="../styles.css" rel="stylesheet" type="text/css">
<script language="JavaScript" src="../script.js"></script>
<body bgcolor="#FFFFFF" text="#000000"><br>
<DIV ID="splashScreen" STYLE="position:absolute;z-index:5;top:241px;left:470px;; width: 304px; height: 46px">
<TABLE HEIGHT=200 WIDTH=300>
<TR>
<TD WIDTH="100%" HEIGHT="100%" ALIGN="left" VALIGN="MIDDLE"> <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="348" height="202">
<param name=movie value="../flash/load.swf">
<param name=quality value=high>
<embed src="../flash/load.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="348" height="202">
</embed>
</object></TD>
</TR>
</TABLE>
</DIV>
<%Response.Flush%>
<TABLE WIDTH=699 BORDER=0 CELLPADDING=0 CELLSPACING=0>
<TR>
<TD> <a href="products.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image21','','../images/english_images/english_productsx.jpg',1)"><img name="Image21" border="0" src="../images/english_images/english_products.jpg" width="98" height="21" alt="Products"></a></TD>
<TD> <a href="industries.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image22','','../images/english_images/english_industriesx.jpg',1)"><img name="Image22" border="0" src="../images/english_images/english_industries.jpg" width="100" height="21" alt="Industries"></a></TD>
<TD> <a href="services.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image23','','../images/english_images/english_servicesx.jpg',1)"><img name="Image23" border="0" src="../images/english_images/english_services.jpg" width="100" height="21" alt="Services"></a></TD>
<TD> <a href="locations.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image24','','../images/english_images/english_locationsx.jpg',1)"><img name="Image24" border="0" src="../images/english_images/english_locations.jpg" width="100" height="21" alt="Locations"></a></TD>
<TD> <a href="aboutus.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image25','','../images/english_images/english_aboutusx.jpg',1)"><img name="Image25" border="0" src="../images/english_images/english_aboutus.jpg" width="99" height="21" alt="About Us"></a></TD>
<TD> <a href="contactus.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image26','','../images/english_images/english_contactusx.jpg',1)"><img name="Image26" border="0" src="../images/english_images/english_contactus.jpg" width="102" height="21" alt="Contact Us"></a></TD>
<TD COLSPAN=3> <a href="index.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image27','','../images/english_images/english_homex.jpg',1)"><img name="Image27" border="0" src="../images/english_images/english_home.jpg" width="100" height="21" alt="Home"></a></TD>
</TR>
</table>
<table width=699 border=0 cellpadding=0 cellspacing=0 background="../images/UBNLpage3_FR.gif" height="525">
<tr>
<td width="1" height="21"></td>
<td valign="top" colspan="2" rowspan="4" CELLPADDING=5> <a href="../pdf/ListProducts.PDF" target="_blank">Product List</a><br>
<a href="../pdf/ListProducts.zip" target="_blank">Download the Product List</a><br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<script language="JavaScript">
<!--
var x = "";
var xDot = "";
var xSlasha = "";
var xSlashb = "";
var xPage = "";
var xSite = "";
var xURL = "";
x = window.location.href;
xDot = x.substring(x.indexOf(".") +1, x.length);
xSlasha = xDot.substring(xDot.indexOf("/") +1, xDot.length);
xSlashb = xSlasha.substring(xSlasha.indexOf("/") +1, xSlasha.length);
xPage = xSlashb.substring(xSlashb.indexOf("/"),xSlashb.length);
xSite = x.substring(0, (x.length + 4) - xSlasha.length);
document.writeln('<TABLE CELLPADDING=5>');
document.writeln('<TR>');
document.writeln('<TD><a href="' + xSite + 'port' + xPage + '" onMouseOver="window.status=\'Portuguese\'; return true;">Portuguese</a><br>');
document.writeln('<a href="' + xSite + 'span' + xPage + '" onMouseOver="window.status=\'Spanish\'; return true;">Spanish</a></TD>');
document.writeln('</TR></TABLE>');
//-->
</script>
</td>
<td width="155" height="21"></td>
<td width="284" height="21"></td>
<td width="79" height="21"></td>
</tr>
<tr>
<td height="139"></td>
<td></td>
<td colspan="2" valign="top">
<div align="right"><img src="../images/products.jpg" width="305" height="100">
</div>
</td>
</tr>
<tr>
<td height="5"></td>
<td height="5"></td>
<td height="5"></td>
<td height="5"></td>
</tr>
<tr>
<td height="87"></td>
<td colspan="3" rowspan="2" valign="top">
<div align="left" class="bodytextbold"> Products</div>
<P> Please fill in the following form to search our products database.
<FORM ACTION="<%=SCRIPT_NAME%>" METHOD="GET">
Search by Product Name:<br>
<INPUT TYPE="text" NAME="Keyword" VALUE="Item" size="33">
<INPUT TYPE="submit" VALUE="Go">
<INPUT TYPE="hidden" NAME="Mode" VALUE="<%=MODE_RESULTS%>">
<INPUT TYPE="hidden" NAME="vis" VALUE="hide">
</FORM>
<form ACTION="<%=SCRIPT_NAME%>" METHOD="GET">
Search by Industry:<br>
<select name='Keyword' size = 1 class="tableextrasmall">
<option Value="">(Elegir una)...</option>
<option Value="Agrochemicals">Agrochemicals</option>
<option Value="Construction & Ceramics">Construction & Ceramics</option>
<option Value="Cosmetics & Pharmaceutical">Cosmetics & Pharmaceutical</option>
<option Value="Detergents">Detergents</option>
<option Value="Electronics">Electronics</option>
<option Value="Graphics and Paper">Graphics and Paper</option>
<option Value="Lubricants & Petrochemicals">Lubricants & Petrochemicals</option>
<option Value="Metallurgy">Metallurgy</option>
<option Value="Plastic & Composites">Plastic & Composites</option>
<option Value="Resins & Chemical">Resins & Chemical</option>
<option Value="Coatings & Adhesives">Coatings & Adhesives</option>
<option Value="Textile & Leather">Textile & Leather</option>
<option Value="Water Treatment">Water Treatment</option>
</select>
<INPUT TYPE='Submit' NAME="<%=MODE_RESULTS%>" value="Go">
<INPUT TYPE="hidden" NAME="Mode" VALUE="<%=MODE_RESULTS%>">
</form>
<P>
</td>
</tr>
<tr>
<td height="71"></td>
<td width="117" height="71"> <br>
<br>
<br>
<br>
<br>
</td>
<td width="63" height="71"></td>
</tr>
<tr>
<td height="4" colspan="2" valign="top"> </td>
<td height="4"></td>
<td colspan="3" valign="top" height="4">
<%
End Function
' Shows HTML page footer
Public Function OutputPageFooter()
%>
<%
End Function
' This function will display the search form
Private Function ShowSearchForm()
OutputPageHeader
%>
<!--
This form will direct user to itself with MODE_RESULTS mode
-->
<%
OutputPageFooter
End Function
' This function will display the results of the search
Private Function ShowResults()
Dim strConn ' Database connection string
Dim SQL ' String that will have our SQL statments
Dim RS ' Recordset object
Dim Keyword ' Keyword for search
Dim nRecCount ' Number of records found
Dim nPageCount ' Number of pages of records we have
Dim nPage ' Current page number
Dim i
' Let's see what page are we looking at right now
nPage = CLng(Request.QueryString("Page"))
' Let's see what user wants to search for today :)
Keyword = Trim(Request.QueryString("Keyword"))
' define our SQL statment
' we will be looking for all the records in tblItem table
' where ItemName contains our Keyword
' do not forget to fix tick marks (single quotes) in our Keyword
SQL = "SELECT * FROM iberiaeng WHERE product LIKE '%" & Replace(Keyword, "'", "''") & "%' OR ceramics LIKE '%" & Replace(Keyword, "'", "''") & "%' OR detergency LIKE '%" & Replace(Keyword, "'", "''") & "%' OR food LIKE '%" & Replace(Keyword, "'", "''") & "%' OR cosmetic LIKE '%" & Replace(Keyword, "'", "''") & "%' OR ink LIKE '%" & Replace(Keyword, "'", "''") & "%' OR textile LIKE '%" & Replace(Keyword, "'", "''") & "%' OR plastic LIKE '%" & Replace(Keyword, "'", "''") & "%' OR water LIKE '%" & Replace(Keyword, "'", "''") & "%' OR paints LIKE '%" & Replace(Keyword, "'", "''") & "%' OR resins LIKE '%" & Replace(Keyword, "'", "''") & "%' OR poliuterins LIKE '%" & Replace(Keyword, "'", "''") & "%' OR feed LIKE '%" & Replace(Keyword, "'", "''") & "%' OR treatment LIKE '%" & Replace(Keyword, "'", "''") & "%' OR lubricants LIKE '%" & Replace(Keyword, "'", "''") & "%' OR automotive LIKE '%" & Replace(Keyword, "'", "''") & "%' OR electronics LIKE '%" & Replace(Keyword, "'", "''") & "%' ORDER BY product "
' Create our connection string
strConn = GetConnectionString()
' Time to create and open recordset
Set RS = Server.CreateObject("ADODB.Recordset")
RS.CursorLocation = 3 ' adUseClient
RS.Open SQL, strConn ' adOpenKeyset CursorType
' Start outputing HTML
OutputPageHeader
' Did we find anything?
If Not RS.Eof Then
' Let's deal with our findings
' Get records count
nRecCount = RS.RecordCount
' Tell recordset to split records in the pages of our size
RS.PageSize = RECORDS_PER_PAGE
' How many pages we've got
nPageCount = RS.PageCount
' Make sure that the Page parameter passed to us is within the range
If nPage < 1 Or nPage > nPageCount Then
' Ops - bad page number
' let's fix it
nPage = 1
End If
' Time to tell user what we've got so far
Response.Write nRecCount & " records found matching ""<font size='2' color ='#0000FF'><b>" & Keyword & "</b></font>"".<br>"
Response.Write nPageCount & " pages of results.<br>"
Response.Write "Current page is " & nPage & ".<p>"
' Start Results
Response.Write"<table width = '100%' border=0><tr><td width = '45%'><p class='results23'><b>Products</b></p></td><td width = '20%'><p class='results23'><b>Supplier</b></p></td><td width '35%'><p class='results23'><b>Details</b></p></td>"
Response.Write "</tr><tr> <td colspan='3' height = '4' bgcolor='#00B8D7'></td>"
' Position recordset to the page we want to see
RS.AbsolutePage = nPage
' Let's output our records
' Loop through records until it's a next page or End of Records
Do While Not (RS.Eof OR RS.AbsolutePage <> nPage)
' All we do here is just show the records
Response.Write "<tr><td>" & RS("product") & "</td><td>" & RS("supplier") & "</td><td>" & RS("details") & "</td></tr>"
' Move on to the next record
RS.MoveNext
Loop
Response.Write "<tr><td colspan='3' height = '4' bgcolor='#00B8D7' align='center'></td></tr></table>"
Else
' We did not find anything
Response.Write "Nothing found. Try again.<br><A HREF=""" & SCRIPT_NAME & """><font color='#0000FF'>Back</font></A><p>"
End If
' Give user some navigation
' first page
' we link to this page with Page parameter = 1
Response.Write "<p align = 'center'><A HREF=""" & SCRIPT_NAME & _
"?Keyword=" & Keyword & _
"&Mode=" & MODE_RESULTS & _
"&Page=" & 1 & _
"""><font color='#0000FF' align='center'>First Page</font></A>"
Response.Write " "
' Previous Page
' we link to this page with Page parameter = Current Page - 1
Response.Write "<A HREF=""" & SCRIPT_NAME & _
"?Keyword=" & Keyword & _
"&Mode=" & MODE_RESULTS & _
"&Page=" & nPage - 1 & _
"""><font color='#0000FF' align='center'>Prev Page</font></A>"
Response.Write " "
' Page2
' we link to this page with Page parameter Current Page + 1
if nPageCount >10 then nPageCount = 10 End If
For i = 1 To nPageCount
if nPageCount < 11 then
Response.Write "<A HREF=""" & SCRIPT_NAME & _
"?Keyword=" & Keyword & _
"&Mode=" & MODE_RESULTS & _
"&Page=" & i & _
"""><font color='#0000FF' align='center'>" & i & "</font></A>"
Response.Write " "
End If
Next
' Next Page
' we link to this page with Page parameter Current Page + 1
Response.Write "<A HREF=""" & SCRIPT_NAME & _
"?Keyword=" & Keyword & _
"&Mode=" & MODE_RESULTS & _
"&Page=" & nPage + 1 & _
"""><font color='#0000FF' align='center'>Next Page</font></A>"
Response.Write " "
' Last Page
' we link to this page with Page parameter = nPageCount
Response.Write "<A HREF=""" & SCRIPT_NAME & _
"?Keyword=" & Keyword & _
"&Mode=" & MODE_RESULTS & _
"&Page=" & nPageCount & _
"""><font color='#0000FF' align='center'>Last Page</font></A></p><br><br>"
' Add and remove text
if Keyword <> "" Then
Response.Write "booooooooooooooo"
End If
' Be nice - close the recordset
RS.Close
' Finish this page
OutputPageFooter
End Function
'************************************************************************************
'* End of Functions section
'************************************************************************************
%>
</td>
</tr>
<tr>
<td height="217"></td>
<td></td>
<td></td>
<td colspan="3" valign="top">
<div id="text">
<p>
To view the Products List in PDF format, please
click here or in the link of the left: <a href="../pdf/ListProducts.PDF" target="_blank"><font color="#0000FF">Product
List</font><br>
</a><br>
In case you would like to download the List of Products click here or in
the link of the left: <br>
<a href="../pdf/ListProducts.zip"><font color="#0000FF">Download Product
List</font></a> <font color="#0000FF"><br>
<br>
</font>If you are unable to see the List of Products will need the Adobe Acrobat Reader. Download it in the following link.
<p> <a href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank"><img src="../images/getacro.gif" border="0"></a>
<p> <a href="javascript:history.go(-1)" onMouseOver="self.status=document.referrer;return true"><font color="#0000CC">Back</font></a><br>
</p></div>
</td>
</tr>
</table>
<%Response.Flush%>
<SCRIPT LANGUAGE="JavaScript">
if(upLevel) {
var splash = document.getElementById("splashScreen");
}
else if(ns4) {
var splash = document.splashScreen;
}
else if(ie4) {
var splash = document.all.splashScreen;
}
hideObject(splash);
</SCRIPT>
</body>
</html>
the page is at http://www.univariberia.com/ibe/engl/products.asp I want the text at the bottom of the page to disappear when a search is done
thanks
pat18581
12-05-2005, 04:22 PM
Does matter know i've worked it out thanks for your help
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.