cfquery ColdFusion execution - sql

Does cfquery execute on every page load? I ask because I'm getting a sequence number with the query and then using it in a form. Unfortunatly, the query seems to execute every time the page loads. I don't want that to happen. I also tried putting it inside of a cffunction and then calling it out of the onSubmit parameter of of the cfinput box that uses the sequence number, but it still calls the sequence.
Here are examples of the way I've tried to do this:
<cfquery name="payment_seq_num" datasource="ORCL">
select ratner01.payment_id_seq.nextval as seq from dual
</cfquery>
<cfset paymentid = payment_seq_num.seq>
And
<cffunction name="getVetSeq" output="false">
<cfquery name="vet_seq_num" datasource="ORCL">
select ratner01.vet_id_seq.nextval as seq from dual
</cfquery>
<cfset vet_form.VET_ID = vet_seq_num.seq>
</cffunction>
I get why the first one keeps incrementing...it's in the head and is called everytime. But why would the second one execute every page load?
Here's how I'm calling it:
<cfform action="vet_output.cfm" method="post" format="html" class="cfform" name="vet_form">
<fieldset>
<legend>Add a Veterinarian to the Databse</legend>
<table>
<tr><cfoutput>
<td><cfinput type="hidden" name="VET_ID" onsubmit="#getVetSeq()#"></td></cfoutput>
</tr>
<tr>
<td>Vet First Name:<br/> <cfinput type="text" name="VET_FNAME" maxlength="35"></td>
<td>Vet Last name: <br/><cfinput type="text" name="VET_LNAME" maxlength="50"></td>
</tr>
<td><cfinput type="submit" value="Insert" name="vetSubmit"></td>
</table>
</fieldset>
</cfform>
So I added this into the output page and removed all related code from the input page, thanks to some suggestions, and it worked... :
<cfquery name="vet_seq_num" datasource="ORCL">
select ratner01.vet_id_seq.nextval as seq from dual
</cfquery>
<cfset FORM.VET_ID = vet_seq_num.seq>
<cfinsert name="insert_vet" datasource="ORCL" username="XX" password="XX"
tablename="VET"
formfields="VET_ID, VET_FNAME, VET_LNAME">

Yeah, so every time this page is loaded you will call that function and get a new sequence number. Because everytime you load the page #getVetSeq()# will be executed by ColdFusion.
I know you put it in onSubmit() but onSubmit() is a JavaScript event, which has no knowledge of ColdFusion. By the time JavaScript sees that code the function has already been called. If you look you'll probably see JS errors because when you click submit you are actually calling a non-existant function. Because your code renders as something like:
onsubmit="1234"
If you only want it called when the form is submitted then do it in your output.cfm instead of in your form.
If for some reason you need to do it on this page instead of in your processing page, then you'll need to look at doing it as an Ajax call so that it only executes onSubmit().

<cfset vet_form.VET_ID = vet_seq_num.seq>
Form values submitted via method="POST" are available in a system structure named FORM. It is always called FORM, regardless of the name assigned to your <form>. So the correct variable name is:
FORM.VET_ID
However, it is cleaner not to access the FORM scope from within the function. Just have the function generate and return the new ID and leave the rest up to the calling page. That makes the function more modular/resuable. But remember to var scope all function local variables (for ColdFusion 9+ use the Local scope)
<!--- Usage --->
<cfset FORM.VET_ID = generateNewVetID()>
<!--- Function --->
<cffunction name="generateNewVetID" output="false" returnType="numeric">
<cfset var vet_seq_num = "">
<cfquery name="vet_seq_num" datasource="ORCL">
SELECT ratner01.vet_id_seq.nextval AS seq
FROM dual
</cfquery>
<cfreturn vet_seq_num.seq>
</cffunction>

Related

Coldfusion URL variable changes unexpectedly

I have an issue that is greatly vexing me. I have written a basic pagination tool for a page that is running on Coldfusion 11: http://fftoolbox.scout.com/ffwc/rankings.cfm?rankings=season&page=2
I have designed it such that there is a url query called page that holds the page number. This way, the user can just type in the page number that he desires rather than having to press the next and previous buttons.
The pagination works just fine for pages 1 - 25, but on page 26 and after, it records the url.page variable as 1, even though the link on the control clearly shows that the variable should be page 26.
If you will notice, I have coldfusion dumping the URL scope at the top of the page. You will note that when the page is equal to 25 or less, the page is reported correctly. Any value over 25, though, url.page is assigned a value 1, even though that is not what is being sent according to the browser. I have tested this in FF, Chrome, and IE, and all exhibit the same behavior. This leads me to believe that it is not something in the code or a browser based peculiarity, but possibly some sort of server setting.
Here is some assorted code of the project:
The dump and setting the session variables.
<cfdump var='#url#'>
<cfif not StructKeyExists(url,'page')>
<cfset session.page = 1>
<cfelse>
<cfset session.page = url.page>
</cfif>
<cfset startingRank = (session.page - 1)*50 +1>
<cfset endingRank = (session.page - 1)*50 +50>
This starting and ending rank are used in an SQL query to retrieve the proper range of players. I am not including the SQL unless someone requests it as that is working fine. In fact, when I hard code the url.page to be 26, everything works as it is supposed to.
The Previous and Next links:
<tr><td colspan='2' style='text-align: center'>
<cfif session.page gt 1>
<a href='./rankings.cfm?rankings=season&action=#Evaluate(session.page - 1)#'>Previous</a>
</cfif></td>
<td colspan='2' style='text-align: center'>
<cfif session.page lt Evaluate(Int((GetMax.recordCount -1)/50) +1)>
<a href='./rankings.cfm?rankings=season&page=#Evaluate(session.page + 1)#'>Next</a>
</cfif></td></tr>
Please let me know if you need any more information. I am thinking that this is actually either an Apache issue or a CF one as the pagination is working properly on pages 1 through 25.
EDIT:
I have had a request to show the queries. There are two of them. One to get the data and another to get the count of the entire set of data.
<cfquery name='GetData' datasource='XXXXXXXX'>
select * from
(select #currentRank := #currentRank +1 as rank,player_name, point_sum, contest_type from
(select player_name,sum(points) as point_sum, contest_type, (select #currentRank := 0) r
from 2014_ranking_season
inner join ecom_item_type on ecom_item_type.ecom_item_type_id = 2014_ranking_season.contest_type
where contest_type = #session.filter#
group by player_name)t1
order by point_sum desc)t2
where rank between #startingRank# and #endingRank#
</cfquery>
<cfquery name='GetMax' datasource='XXXXXXXX'>
select * from
(select #currentRank := #currentRank +1 as rank,player_name, point_sum, contest_type from
(select player_name,sum(points) as point_sum, contest_type, (select #currentRank := 0) r
from 2014_ranking_season
inner join ecom_item_type on ecom_item_type.ecom_item_type_id = 2014_ranking_season.contest_type
where contest_type = #session.filter#
group by player_name)t1
order by point_sum desc)t2
</cfquery>
I hope that helps. Please bear in mind that except for the previous button with which I am experimenting, everything works fine until page > 25.
EDIT:
The value for GetMax.recordCount = 2242. Also, I am writing a small reproduction page that is scaled down to just produce the results. Once it is done, I will post the code of the entire page. Whether or not it reproduces the result it will tell us SOMETHING.
EDIT:
The reproduction page is in place and the error IS reproducible, even with the scaled down code. Here is the URL: http://fftoolbox.scout.com/ffwc/testPagination.cfm?rankings=season&page=26
Here is the entire code listing:
<cfdump var='#url#'>
<cfset session.page = 1>
<cfif StructKeyExists(url,'page')>
<cfset session.page = url.page>
</cfif>
<cfset startingRank = (session.page - 1)*50 +1>
<cfset endingRank = (session.page - 1)*50 +50>
<cfif not StructKeyExists(session,'filter')>
<cfset session.filter = 0>
</cfif>
<cfparam name="url.rankings" default="season">
<html>
<head>
<title>Test Pagination</title>
</head>
<body>
<br /><br />
<cfoutput>
<table width='99%' cellpadding='5' cellspacing='0'><tr class='header'>
<cfset count = 0>
<cfquery name='GetData' datasource='fftoolbox_sql'>
select * from
(select #currentRank := #currentRank +1 as rank,player_name, point_sum, contest_type from
(select player_name,sum(points) as point_sum, contest_type, (select #currentRank := 0) r
from 2014_ranking_season
inner join ecom_item_type on ecom_item_type.ecom_item_type_id = 2014_ranking_season.contest_type
group by player_name)t1
order by point_sum desc)t2
where rank between #startingRank# and #endingRank#
</cfquery>
<cfquery name='GetMax' datasource='fftoolbox_sql'>
select * from
(select #currentRank := #currentRank +1 as rank,player_name, point_sum, contest_type from
(select player_name,sum(points) as point_sum, contest_type, (select #currentRank := 0) r
from 2014_ranking_season
inner join ecom_item_type on ecom_item_type.ecom_item_type_id = 2014_ranking_season.contest_type
group by player_name)t1
order by point_sum desc)t2
</cfquery>
<th>RANK</th><th>PLAYER NAME</th><th>TEAM NAME</th><th>POINTS</th></tr>
<cfloop query='GetData'>
<cfquery name='GetOneName' datasource='fftoolbox_sql'>
select team_name
from 2014_ranking_season
where player_name = <cfqueryparam cfsqltype='CF_SQL_VARCHAR' value='#GetData.player_name#'>
limit 1
</cfquery>
<cfset name = URLEncodedFormat(#player_name#)>
<tr <cfif #count#%2 eq 0>class='evenRow'<cfelse>class='oddRow'</cfif>><td>#rank#</td>
<td><a href='./player.cfm?name=#variables.name#' target='_blank'>#player_name#</a></td><td>#GetOneName.team_name#</td><td>#point_sum#</td></tr>
<cfset count++>
</cfloop>
<tr><td colspan='2' style='text-align: center'>
<cfif session.page gt 1>
<a href='./testPagination.cfm?rankings=season&page=#Evaluate(session.page - 1)#'>Previous</a>
</cfif></td>
<td colspan='2' style='text-align: center'>
<cfif session.page lt Evaluate(Int((GetMax.recordCount -1)/50) +1)>
<a href='./testPagination.cfm?rankings=season&page=#Evaluate(session.page + 1)#'>Next</a>
</cfif></td></tr>
</table>
</cfoutput>
</body>
</html>
I will also get the http request headers to display on that page. I will put them in the question, if people want, but the question is starting to get long, and the cfdump formats it nicely in the browser. Thank you, everyone for the interaction so far.
UPDATE:
I am suspecting that our provisioning team, over whom I have no control, might have done something on the backend, such as put it on Varnish, which is not supposed to happen. Please continue to look at the code, etc, and I will bark up this tree to see if there is something they have done. 25 just seems like to "human" a number for it not to be a setting somewhere. I will keep you posted.
UPDATE:
I have checked with the provisioning team, and Varnish is not active, and the load balance is NOT causing the issue, as I could replicate the issue when bypassing the LB. My opinion that it is a configuration issue with Apache or CF seems to be becoming more and more likely as we rule things out.
UPDATE:
Upon adding the code that #Leigh recommended, we find that the http request is definitely page=26, and the URL scope is definitely page=1. I am looking to see if an Application file might be messing with it.
FINAL UPDATE:
Upon examining the Application.cfm, I found the following code:
<cfif cgi.script_name NEQ "/ffwc/all-time-leaderboard.cfm">
<cfset ValidPages = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25">
<cfif IsDefined("url.page") and ListFind(ValidPages,url.page) eq 0>
<cfset url.page = 1>
</cfif>
</cfif>
After this was commented out, the pagination worked just fine. Another alternative method of making it work would be to not use page as the variable name for the page. (This is counter intuitive and distasteful to me) I hold the opinion that constructs like pagination should be contained within one file or directory, and not be site wide.
Upon examining the Application.cfm, I found the following code:
<cfif cgi.script_name NEQ "/ffwc/all-time-leaderboard.cfm">
<cfset ValidPages = "1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25">
<cfif IsDefined("url.page") and ListFind(ValidPages,url.page) eq 0>
<cfset url.page = 1>
</cfif>
</cfif>
After this was commented out, the pagination worked just fine. Another alternative method of making it work would be to not use page as the variable name for the page. (This is counter intuitive and distasteful to me) I hold the opinion that constructs like pagination should be contained within one file or directory, and not be site wide.
Thank you to all that commented, and helped me in this endeavor.
First of all, your "previous" button isn't setting a URL.page or session.page - it's using "action." Since page isn't defined in the URL it automatically sets the page to one... So clicking "previous" and then "next" always sets me back to page 2 no matter where I start.
Now, your "next" link...
<cfif session.page lt Evaluate(Int((GetMax.recordCount -1)/50) +1)>
<a href='./rankings.cfm?rankings=season&page=#Evaluate(session.page + 1)#'>Next</a>
</cfif>
I just ran this code after setting session.page on my own .cfm page...
A "Next" button will only ever show up if session.page is zero or GetMax.recordcount is more than 50x the value of session.page. I raise issue with that because GetMax.recordcount shouldn't ever change. You're displaying 50 records at a time.
The following code doesn't work so I don't what you're doing on your end...
<cfset GetMax.recordcount = 50>
<cfset session.page = 1>
<cfoutput>
<cfif session.page lt Evaluate(Int((GetMax.recordCount -1)/50) +1)>
<a href='./rankings.cfm?rankings=season&page=#Evaluate(session.page + 1)#'>Next</a>
</cfif>
</cfoutput>
It might be time to show us the query logic.
Edit:
Why not do something like this?
<cfset StartRecord = #url.page# * 50 - 49>
<cfquery name="listOfPeople" datasource="XXX">
SELECT TOP 50 *
FROM PeopleTable
WHERE PeopleID >= #StartRecord#
</cfquery>
It's so simple and I'm just not getting why the query GetMax is needed. All that extra math involved just heightens the risk for error. Pagination shouldn't be a project unto itself.

How do I populate a name value inside a Coldfusion CFOUTPUT

This is an update from a previous question. I'm not sure if this is even possible but I have a CFOUTPUT tag that has a single input tag inside it. This input tag equates to 65 possible checkboxes. The problem I'm having is trying to figure out what value to put in the name attribute of the input tag. I need 22 unique names that are static and don't change. My code is as follows:
<form action="new_processOptInfo.cfm" id="displayOptions" method="post" name="displayOptions">
<cfoutput query="categorize" group="categoryName">
<h3>#UCASE(categoryName)#</h3>
<cfoutput>
<input type="checkbox" value="#idOptions#" name="option1" /> #option#<br>
</cfoutput>
</cfoutput>
<input type="submit" value="Submit" name="submitOptions" id="submitOptions" />
</form>
So how do I name the input tag?
In reply to a comment OP made.
In plain English I want to have unique names for my checkboxes that are generated automatically. I thought that when you INSERT values into a table the form tag names have to be unique
(This reply was just too many characters to leave as a comment.)
For the record, field names don't have to be unique. Cold Fusion receives duplicate field names' values in a comma delimited list. There's actually great use in that. You can have 50 checkbox named p_IDs and if 3 are checked cold fusion will recieve the values checked (like 7,15,32, if those were the values checked).
This is extremely useful with cfloops like
<cfloop list="#form.p_IDs#" index="p">Product #p# selected</cfloop>.
You can name corresponding input field, like textboxes like
<input name="desc_#dbID#" type="text">
<input type="checkbox" name="p_IDs" value="#dbID#">
And then in the cfloop on processing page use code like
<cfloop list="#form.p_IDs#" index="p">
Product #p#'s description is #form["desc_#p#"]#
</cfloop>
You could place an insert query into the cfloop (or an update, or delete query).
Examples of where this is useable is say if you wanted to mass delete selected rows, rather than deleting each row individually.
This functionality (works in a similar fashion across nearly every language) is the beauty of checkboxes. You can name them different things, but why would you want to? As far as radio buttons, naming them different things defeats their purpose.
On the subject of other input elements though, certainly name them different things.
As #FishBelowtheIce said option1 is being sent to the action page as a list so when I was made aware of that and looped through it. I just had to fix my typos and it worked. The code below is what I have now.
<cfif IsDefined("form.submitOptions")>
<cfloop index="index" list="#options#" delimiters="," >
<cfquery name="updateInsOpTable" datasource="applewood">
INSERT INTO ins_opt_table
( address,option1,option2,option3,option4,option5,option6
, option7,option8,option9,option10,option11,option12
, option13,option14,option15,option16,option17,option18
)
VALUES (#form.address#, #options#)
</cfquery>
</cfloop>
</cfif>

ColdFusion Query Output Displaying Variable Name Instead Of Field Value

I'm an "old dog" and largely self-taught on this stuff and can usually make things work (primative and convoluted as it might be), but this is the first thing that has me really stymied.
I didn't want to burden everyone with a lot of stuff to try to explain, but, here is perhaps a better explanation and example:
(#Leigh - and thank you for your time and help!) - The query is dynamic because what I desire to have is a single "universal" page combination (form page plus accompanying action page) that is used to edit multiple different (but fairly similar) record sets (so that I don't have to write a whole bunch of individual form/action page pairs).
When this "universal" "change" form page is invoked, it is passed the "ID" variable for the particular record to be edited, along with a "listID" variable unique to the particular record set containing the record to be edited.
Using the "URL.listID", the form page then looks at a pre-defined included list of record set variables (datasource, query table, field for column 1, field for column 2, etc.) pertaining to the value of the "listID" and sets (using ) the dynamic variables. Example - if "listID" is "5", which has only one column:
<cfif #URL.listID# EQ 5>
<cfset page_title = 'Change Member Role Picklist'>
<cfset datasource = '#Session.db_docs#'>
<cfset query_tbl = 'tblMemberRole'>
<cfset columns = 1>
<cfset column1_label = 'Member Role'>
<cfset column1_field = "role">
<cfset column1_input_type = "text">
<cfset column1_input_size = "100">
<cfset column1_input_maxlength = "100">
</cfif>
The query uses those variables ("ID" plus the others it got from the above list) to retrieve the individual record to be edited, and populate the "change" form.
Run query:
<cfquery name="cfqGetItem" datasource="#datasource#">
SELECT *
FROM #query_tbl#
WHERE ID = <cfqueryparam value="#URL.ID#" cfsqltype="cf_sql_integer">
</cfquery>
My "change" form (abbreviated here without table HTML) to be populated would be:
<form name="form_item_chg" action="chg_item2.cfm" method="post" enctype="multipart/form-data">
<input type="text" name="#column1_field#" maxlength="#column1_input_maxlength#" size="#column1_input_size#" value="#cfqGetItem[column1_field][currentRow]#">
<input type="Submit" value="Post Changes">
</form>
However, instead of the "change" form being populated with the VALUE for field "role", it instead is trying to use the variable name "column1_field", which it says is (true, of course) undefined in the query.
When I tried "#cfqGetItem[column1_field][currentRow]#", it says "Variable currentrow is not defined".
When I tried "#cfqGetItem.column1_field#", it says "Element column1_field is not defined in query cfqGetItem".
I apologize in advance for not knowing/using all the correct terminology, and hope I am explaining this reasonably clearly. I suspect I will have to revert to writing individual form-page/action-page pairs. Thank you to all for your time and help!
ORIGINAL POST:
I'm not highly technical, and this is probably something simple, but here is
my dilemma, where I am attempting to retrieve a single record using a variable name in the query.
First, I define some variables:
<cfset ID = #Form.ID#<!--- the single record I want to retrieve, passed from a form --->
<cfset datasource = 'MyDatabase'>
<cfset query_tbl = 'MyDatabaseTable'>
<cfset field1 = 'actual_fieldname1'><!--- field in MyDatabaseTable --->
<cfset field2 = 'actual_fieldname2'><!--- field in MyDatabaseTable --->
ETC.
Then, to retrieve this single record, I run a query using those variables:
<cfquery name="cfqGetItem" datasource="#datasource#">
SELECT *
FROM #query_tbl#
WHERE ID = #ID#
</cfquery>
Then, I attempt to display the query output:
EITHER AS
<cfoutput>
<p>#cfqGetItem.field1#
<p>#cfqGetItem.field2#
</cfoutput>
OR, AS
<cfoutput>
<p>#cfqGetItem[field1][currentRow]#
<p>#cfqGetItem[field2][currentRow]#
</cfoutput>
In each case, I get a similar CF error message: "Element field1 is not defined in query cfqGetItem", or "Variable currentrow is not defined".
How can I get the query output to generate the actual values for the record instead of the variable names?
Thank you very much for any help!
If you change this:
<cfoutput>
<p>#cfqGetItem[field1][currentRow]#
<p>#cfqGetItem[field2][currentRow]#
</cfoutput>
to this:
<cfoutput>
<cfloop query="cfqGetItem">
<p>#cfqGetItem[field1][currentRow]#
<p>#cfqGetItem[field2][currentRow]#
</cfloop>
</cfoutput>
You should be ok. However, this is the simplest way
<cfoutput query="cfqGetItem">
<p>#actual_fieldname1#
<p>#actual_fieldname1#
</cfoutput>
Setting the table and field names to variables complicates matters. Unless they really can vary, don't do it. Also, the cfqueryparam tag is your friend. Use it in places like this:
where id = <cfqueryparam
cfsqltype = "cf_sql_integer"
value = "#id#">
You can try out like this also:
<cfquery
name="GetParks" datasource="cfdocexamples"
>
SELECT PARKNAME, REGION, STATE
FROM Parks
ORDER BY ParkName, State
</cfquery>
<cfoutput>
<p>#GetParks.PARKNAME#
<p>#GetParks.REGION#
</cfoutput>
<cfoutput >
#GetParks['state'][GetParks.RecordCount]#
</cfoutput>
<cfoutput >
#GetParks['state'][2]#
</cfoutput>

Access resultset value of cfprocresult name in cfif

I am new to ColdFusion and want to rewrite my project from ASP.NET to learn ColdFusion step by step.
My SQL Server stored procedure for authentication (ASP.NET) looks like this:
CREATE PROCEDURE sp_auth
#suser VARCHAR(20),
#spswd VARCHAR(20)
AS
SELECT COUNT(*) FROM Users.SUsers WHERE suname=#suser AND supasswd=#spswd AND off_bit=0
GO
Application.cfc snippet.
<cfstoredproc procedure="sp_auth" datasource="cftraderelay">
<cfprocparam value="#cflogin.name#" cfsqltype="CF_SQL_VARCHAR" maxlength="20" type="in">
<cfprocparam value="#cflogin.password#" cfsqltype="CF_SQL_VARCHAR" maxlength="20" type="in">
<cfprocresult name="auth_pass" maxrows="1">
</cfstoredproc>
<cfif auth_pass GTE 1>
<cfloginuser name="#cflogin.name#" password = "#cflogin.password#" roles="#roles#">
<cfelse>
<cfoutput>
<h2>Your login information is not valid.<br> Please Try again</h2>
</cfoutput>
<cfinclude template="login.cfm">
<cfabort>
</cfif>
What is right form of 'cfif auth_pass GTE 1' logic? How to access the value of 'auth_pass'.
Cos I get "Complex object types cannot be converted to simple values" error by far.
Am I strictly supposed to use out type of cfprocparam in this case, not cfprocresult (modify SQL query for the OUTPUT variable)?
Can I access cfprocresult value right in the cfif statement?
auth_pass contains a recordset, not a number, so you cannot compare it to 1. You perhaps want auth_pass.recordCount?
The best tool for examining the contents of a variable is <cfdump>. That and familiairising yourself with the docs for the code you're using, eg: <cfprocresult>, <cfstoredproc>, <cfquery> (the latter for details on query objects) if you run into problems and can't guess the solution.

How do I grab the variable NAME and not the VALUE of the variable in ColdFusion?

The basic idea is this: I have a form that generates form fields dynamically so let's say there are 5 evens people can sign up for (they all cost $10) then those 5 evens will be displayed. Like this:
<tr>
<th><label>#SeminarWisTitle#</label></th>
<td>
<label><input type="checkbox" name="#SeminarWisID#" value="10.00" onclick="CheckChoice(this);" onfocus="startCalc();" onblur="stopCalc();" class="checkbox" /> Individual Webinar ($119)</label>
</tr>
</cfoutput>
Now because of the Javascript the value on all these events will be 10.00 but the NAME of the form field will be unique, and that is what I actaully want to store in the database.
This is the code I've written:
<cfparam name="seminarBulkSignUp_List" default="">
<cfoutput query="qSeminarWisTwo">
<cfparam name="FORM.#SeminarWisID#" default="">
<cfif #FORM[#SeminarWisID#]# neq "">
<cfset seminarBulkSignUp_List = ListAppend(seminarBulkSignUp_List, #FORM[#SeminarWisID#]#)>
</cfif>
</cfoutput>
<cfset FORM.SeminarWisTitle = #seminarBulkSignUp_List#>
So with this code, I run a query for ALL the possible events, and then just check against the form that has been submitted to see which ones are "blank" as in not selected, and the ones that are selected i want to add to a list to store in the database.
Now this works as far as letting me know which events were selected and which not, but i want the list to compile the actual FORM FIELD names not the value they have. How would I do that?
<cfoutput>
<cfloop list="#StructKeyList(FORM)#" index="thisField">
My field name: #thisField#<br/>
My field value: #FORM[thisField]#<br/>
</cfloop>
</cfoutput>
Apply as necessary.