Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing URL variable containing multiple values

Status
Not open for further replies.

lminmei

Programmer
Feb 1, 2000
111
US
I have a list box that allows for multiple value selections. when i submit this, the results page comes out clean HOWEVER....when i click on the (ex: "next 5 records") button....i get an error about that listbox URL variable.
>>example.................

on my search.cfm page I have a list box:

<CFQUERY DATASOURCE=&quot;Advice2000&quot; NAME=&quot;Issues&quot;>
SELECT Issues
FROM ISSUES
GROUP BY Issues
ORDER BY Issues
</CFQUERY>

<select name=&quot;GetIssues&quot; size=&quot;5&quot; multiple>
<option value=&quot;&quot; Selected>All
<cfoutput query=&quot;Issues&quot;>
<option value=&quot;#Issues#&quot;>#Issues# </cfoutput>
</select>

Now on my results.cfm page i have:
<a href=&quot;results.cfm?Issues=#GetIssues#&quot;>

i don't know what else i have to add...
Please Help!!!
 
I'm pretty new to CF myself, but here's my two cents worth:


search.cfm&quot;

<CFQUERY DATASOURCE=&quot;Advice2000&quot; NAME=&quot;Issues&quot;>
SELECT Issues
FROM Issues
GROUP BY Issues
ORDER BY Issues
</CFQUERY>

<cfoutput query=&quot;Issues&quot;>

<FORM ACTION=results.cfm?GetIssues=#Issues#>
<select name=&quot;GetIssues&quot; size=&quot;5&quot; multiple>
<option value=&quot; &quot; Selected>
All
<option value=&quot;#Issues#&quot;>#Issues#
</select>
<BR>
<INPUT TYPE=&quot;Submit&quot; VALUE=&quot;Search&quot;>
</FORM>
</cfoutput>

results.cfm page:
<CFQUERY DATASOURCE=&quot;Advice2000&quot; NAME=&quot;Results&quot;>
SELECT Issues
FROM Issues
WHERE FORM.GetIssues = #FORM.Issues#
ORDER BY Issues
</CFQUERY>

<cfoutput query=&quot;Results&quot;>
#Issues#
</CFOUTPUT>

Hope this helped . . . if not, I would need more detail in what you want your results to be.

-NeoTurtle
 
NeoTurtle,

you suggestion won't work because i'm gonna need to add a link that will show &quot;the next 5 records&quot;
but in your code...the &quot;WHERE&quot; sql statement is looking for a form variable. So that code would only work for the first page of records.
 
In your results.cfm page, you could do something like:
Code:
<CFPARAM NAME = &quot;Issues&quot; default=&quot;&quot;>
<CFPARAM NAME = &quot;Page&quot; default=1>
<CFSET Start = ((Page - 1)* 5) + 1>

<CFIF len(Issues)>

  <CFQUERY DATASOURCE=&quot;Advice2000&quot; NAME=&quot;Results&quot;>
    SELECT Issues
    FROM Issues
    WHERE Issues = '#Issues#'
    ORDER BY Issues
  </CFQUERY>

  <CFOUTPUT QUERY=&quot;Results&quot; STARTROW=&quot;#Start#&quot; MAXROWS=5>
    <P>#Issues#</P>
  </CFOUTPUT>

  <CFIF Start + 5 lt Results.Recordcount>
    <CFSET NextPage=Page+1>
    <CFOUTPUT>
      <A HREF=&quot;results.cfm?issues=#UrlEncodedFormat(issues)#&page=#NextPage#&quot;>Next 5 Results</A>
    </CFOUTPUT>
  </CFIF>

<CFELSE>

  Click <A HREF=&quot;search.cfm&quot;>Here</A> to select a search option

</CFIF>
Hope this helps...

DM
 
DarkMan,

I'm not sure what i'm doing wrong but for the multiple select list box, i used the function &quot;ListChangeDelims() in the query and the number of records to display is a combo box from the search page (it is a variable called &quot;records to display&quot;)...please take a look at my entire code....here it is:

results.cfm:

<HTML>
<HEAD>
<TITLE>Advice Letter Search Results</TITLE>
<CFQUERY name=&quot;Result&quot; datasource=&quot;Advice2000&quot;>
SELECT ID, Analyst, Year, DateIss, AdvNbr, Issues,
IssDescrp, LastName, FirstName, LawSec
FROM ISSUES
WHERE ID = ID
<CFIF IsDefined(&quot;Form.FirstName&quot;) IS &quot;Yes&quot;>
<CFIF Form.FirstName IS NOT &quot;&quot;>AND FirstName LIKE '%
#Form.FirstName#%'
</CFIF>
</CFIF>

<CFIF IsDefined(&quot;Form.LastName&quot;) IS &quot;Yes&quot;>
<CFIF Form.LastName IS NOT &quot;&quot;>AND LastName LIKE '%
#Form.LastName#%'
</CFIF>
</CFIF>

<CFIF IsDefined(&quot;Form.Year&quot;) IS &quot;Yes&quot;>
<CFIF Form.Year IS NOT &quot;All&quot;>AND Year Like '%
#Form.Year#%'
</CFIF>
</CFIF>

<CFIF IsDefined(&quot;Form.Issues&quot;) IS &quot;Yes&quot;>
<CFIF Form.Issues IS NOT &quot;&quot;>AND (Issues
LIKE '#ListChangeDelims(Form.Issues,&quot;'OR Issues LIKE'&quot;)
#')
</CFIF>
</CFIF>

<CFIF IsDefined(&quot;Form.LawSection&quot;) IS &quot;Yes&quot;>
<CFIF Form.LawSection IS NOT &quot;&quot;>AND LawSec LIKE '%
#Form.LawSection#%'
</CFIF>
</CFIF>

<CFIF IsDefined(&quot;Form.IssDescrp&quot;) IS &quot;Yes&quot;>
<CFIF Form.IssDescrp IS NOT &quot;&quot;>And IssDescrp LIKE '%
#Form.IssDescrp#%'
</CFIF>
</CFIF>

ORDER BY AdvNbr
</CFQUERY>

<CFPARAM name=&quot;StartRecord&quot; default=&quot;1&quot;>
<CFIF IsDefined(&quot;StartRecord&quot;)>
<CFSET NextRecord = #StartRecord# + #records_to_display#>
</CFIF>

</HEAD>
<BODY>

<cfoutput>
<table>
<tr>
<td>
<CFIF #StartRecord# IS NOT 1>
<a href=&quot;Adviceresults.cfm?StartRecord=#Evaluate
(StartRecord - records_to_display)#&records_to_display=#records_to_display#&Year=#Year#&FirstName=#FirstName#&LastName=#LastName#&IssDescrp=#IssDescrp#&LawSec=#LawSec#&Issues=#UrlEncodedFormat(Issues)#&quot;>Previous #records_to_display#</a>
</CFIF>
</TD>
<TD align=&quot;right&quot;>
<CFIF #NextRecord# LTE result.recordcount>
<CFIF #Evaluate(NextRecord + #records_to_display# - 1)
# GT result.recordcount> <CFSET LastRecord = #result.recordcount# MOD
#records_to_display#>

<a href=&quot;Adviceresults.cfm?StartRecord=#nextRecord#&records_to_display=#records_to_display#&Year=#Year#&FirstName=#FirstName#&LastName=#LastName#&IssDescrp=#IssDescrp#&LawSec=#LawSec#&Issues=#UrlEncodedFormat(Issues)#&quot;>Next #LastRecord#</a>

<CFELSE>
<a href=&quot;Adviceresults.cfm?StartRecord=#NextRecord#&records_to_display=#records_to_display#&Year=#Year#&FirstName=#FirstName#&LastName=#LastName#&IssDescrp=#IssDescrp#&LawSec=#LawSec#&Issues=#UrlEncodedFormat(Issues)#&quot;>Next #records_to_display#</a>

</CFIF>
</CFIF>

The rest is just displaying the records....
my problem is this, the query works for the first page but when i click on the nect 5 button...the variables are not being passed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top