Hubert,
Since I don't have a database with more than five jokes in it to test this
against, I do not guarantee that it will work, this was just the answer that
broke through my caffeine-sugar buzz... ;). Besides, it's 5 AM, for Christ's
sake--what are we still doing on the list?
I would say the easiest and simplest technique would be to turn their
answers into a list (on the action page). I know lists aren't the fastest
[execution wise] means to accomplish this. Nevertheless, I tend to use a lot
of lists for simpler, quick-n-dirty processing of form fields and I don't
worry much about mere milliseconds of bandwidth usually. The primary reason
I would use a list is that you are already sending a comma-delimited,
"name=value" list to the action page: "a,a,a,a,a" -- rather confusing,
wouldn't you agree? S-o-o-o, let the computer figure it out:
<!--- The following puts all their answers in a comma delimited list AND
gets rid of the ambiguous "a" variable name, which
would be pretty confusing to deal with otherwise --->
<!--- Instantiate a NULL list to hold the values --->
<CFSET jokeList = "">
<!--- Fill the list with their answers --->
<CFLOOP FROM="1" TO="5" INDEX="jokeIndex" DELIMITERS=",">
<CFSET ListAppend(jokeList, jokeID)>
</CFLOOP>
<!--- Use the SQL "IN" operator to find just those IDs that are contained in
the list chosen by your surfer. This SQL
statement should only get those jokes where jokeID is contained within
the finite list you just created instead of
searching the entire table --->
<CFQUERY NAME="jokeData" DATASOURCE="Jokes">
SELECT jokeID, joke
FROM wordJokes
WHERE jokeID IN #jokeList#
</CFQUERY>
<!--- Now turn the result set (the joke TEXT) into another list for easy
manipulation later --->
<CFSET resultSet = "">
<CFSET resultSet = #ValueList(jokeData.joke)#>
<!--- Now output their jokes on the display page --->
<CFLOOP LIST="resultSet" INDEX="resultIndex">
<CFOUTPUT>
<TABLE>
<TR>
<TD>#resultIndex#</TD>
</TR>
</TABLE>
</CFOUTPUT>
</CFLOOP>
Alternatively:
<!--- Another means of outputting their joke list on the display page. --->
<CFLOOP FROM="1" TO="#ListLen(resultSet)#" INDEX="resultIndex">
<CFOUTPUT>
<TABLE>
<TR>
<TD>#ListGetAt(resultSet, resultIndex)#</TD>
</TR>
</TABLE>
</CFOUTPUT>
</CFLOOP>
Or however you wish to output it. I used a table to make a point. You can
use any HTML methodology in its place that suits your needs.
This code may need a bit of finessing and tweaking but you should be able to
massage it into working. As I said, there are many ways of accomplishing
this. This is merely the first thing that popped into my head when I read
your question.
Cheers,
--
David L. Rice
Web Development Consultant
[EMAIL PROTECTED]
Q: 177820
24/7 cell: 770.354.5953
----------------------------
> -----Original Message-----
> From: Hubert Earl [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, April 25, 2000 2:18 AM
> To: [EMAIL PROTECTED]
> Subject: Problem controlling output
>
>
> Hi,
>
> I'm having a problem controlling the output of a form. I
> have a form which
> allows the user to choose up to 5 joke titles from a joke
> database, and a
> form action template which should result in the output of just those 5
> jokes, the titles of which were chosen on the form. However,
> the entire
> database gets output. I've pasted the code of the form and
> action template
> below. Please advise me.
>
> The form code:
>
> <CFQUERY
> DATASOURCE="Jokes"
> NAME="Titles">
>
> SELECT JokeID, JokeTitle
> FROM WordJokes
> ORDER BY JokeTitle
> </CFQUERY>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>
> <html>
> <head>
> <title>Jokes</title>
> </head>
>
> <body>
>
> <h1>JOKES</h1>
>
> <FORM ACTION="jokesaction.cfm" METHOD="POST">
>
> Please select joke titles from the contents of the select
> boxes below. You
> may select up to five titles at a time.<P>
>
> Joke title #1:
> <SELECT NAME="a">
> <OPTION>
> <CFOUTPUT QUERY="Titles">
> <OPTION VALUE="#JokeID#">#JokeTitle#
> </cfoutput>
> </select><P>
>
> Joke title #2:
> <SELECT NAME="a">
> <OPTION>
> <CFOUTPUT QUERY="Titles">
> <OPTION VALUE="#JokeID#">#JokeTitle#
> </cfoutput>
> </select><P>
>
> Joke title #3:
> <SELECT NAME="a">
> <OPTION>
> <CFOUTPUT QUERY="Titles">
> <OPTION VALUE="#JokeID#">#JokeTitle#
> </cfoutput>
> </select><P>
>
> Joke title #4:
> <SELECT NAME="a">
> <OPTION>
> <CFOUTPUT QUERY="Titles">
> <OPTION VALUE="#JokeID#">#JokeTitle#
> </cfoutput>
> </select><P>
>
> Joke title #5:
> <SELECT NAME="a">
> <OPTION>
> <CFOUTPUT QUERY="Titles">
> <OPTION VALUE="#JokeID#">#JokeTitle#
> </cfoutput>
> </select><P>
>
> <INPUT TYPE="submit" VALUE="Submit choice(s)">
> <INPUT TYPE="reset" VALUE="Clear">
>
> </FORM>
> </body>
> </html>
>
> --------------------------------------------------------------
> --------------
> ------------------------------------------
>
> The form action template:
>
> <CFQUERY
> DATASOURCE="Jokes"
> NAME="JokeData">
> SELECT Joke
> FROM WordJokes
> WHERE JokeTitle=JokeTitle
> </CFQUERY>
>
>
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>
> <HTML>
> <HEAD>
> <TITLE>JokeAction</TITLE>
> </HEAD>
>
> <BODY>
>
> <CFOUTPUT QUERY="JokeData">#Joke#</CFOUTPUT>
>
> </BODY>
> </HTML>
>
> ---
> Hubert Earl
> ICQ#: 16199853
>
> I develop & maintain web sites internationally. I also build web
> applications using CGI scripts written in Perl. I accept
> subcontracting
> work.
>
> **Personal web site:
> http://www.geocities.com/SiliconValley/Peaks/8702/
> (please remember to view this with a sense of humour!)
>
> **Business web page: http://home.talkcity.com/MigrationPath/hearl/
>
> --------------------------------------------------------------
> ----------------
> Archives: http://www.eGroups.com/list/cf-talk
> To Unsubscribe visit
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=list
s/cf_talk or send a message to [EMAIL PROTECTED] with
'unsubscribe' in the body.
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.