By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,006 Members | 1,238 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,006 IT Pros & Developers. It's quick & easy.

passing search form information

P: 22
Hi Peoples
i have a search page with a form field "subject" on my results page i have a paging routine . the first page lists its 10 records no trouble but when i click the "next" link i get a error telling me "subject is not defined in form"
How can i overcome this please.
I will post the page down to the end of the paging routine coz its not very long anyway.

[HTML]<cfquery name="searchResults" datasource="#dsn#">
SELECT threadID, posttype, topic, topicID, postdate, username, threads.catID, posttext, categories.catID, category
FROM threads INNER JOIN categories
ON threads.catID=categories.catID
WHERE topic LIKE '#form.subject# %' OR topic LIKE '% #form.subject#' OR topic LIKE '% #form.subject# %' OR topic LIKE '#form.subject#'
OR username LIKE '#form.subject#'
OR posttext LIKE '#form.subject# %' OR posttext LIKE '% #form.subject#' OR posttext LIKE '% #form.subject# %' OR posttext LIKE '#form.subject#'

<!---Set the number of entries (records) per page--->
<cfset perPage = 10>
<!--- Set the parameter "url.start" default to 1--->
<cfparam name="url.start" default="1">
<cfif not isNumeric(url.start) or url.start lt 1 or url.start gt searchresults.recordCount or round(url.start)
neq url.start>
<cfset url.start = 1>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="JavaScript" type="text/JavaScript">
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
<link href="CSStyle/forum.css" rel="stylesheet" type="text/css">


<div id="Layer2" style="position:absolute; left:0; top:0; width:30px; height:23px; z-index:6">
<cfinclude template="header.cfm">
<div id="Layer3" style="position:absolute; left:75px; top:190; width:850; height:83px; z-index:7">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<td colspan="2"><span class="standard33">Your search for</span> <span class="standardred">'#form.subject#'</span> <span class="standard33">returned </span><span class="standardred">'#searchResults.RecordCount#'</span> <span class="standard33">results.</span></td>
<tr class="standard">
<td colspan="3" align="right">
<cfif url.start gt 1>
<cfset link = cgi.script_name & "?start=" & (url.start - perpage) & "&subject=" & "#subject#">
<span class="small11-33"><a href="#link#">&lt;&lt; Previous</a></span>
<img src="siteImages/navSeperator.gif" width="5" height="5">
<cfif (url.start + perpage - 1) lt searchresults.recordCount>
<cfset link = cgi.script_name & "?start=" & (url.start + perpage) & "&subject=" & "#subject#">
<span class="small11-33"><a href="#link#">Next &gt;&gt; </a></span>

Cheers and thanks in advance
Mar 13 '07 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 16,027
The problem is that 'form' is for POST variables and you are trying to access form.subject without having posted the variable. The solution is to use url.subject and pass the form.subject value in the link, e.g
Expand|Select|Wrap|Line Numbers
  1. nextpage.cfm?subject=#form.subject#
Be sure to use cfparam to set a default in case someone comes along and alters the url. Normally, for searches, I just use the URL so that it's easy to support navigational previous/next links.
Mar 13 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.