Janine,
I use this to loop over the form collection. I just had to deal with this
situation. you can take advantage of the fact that radio buttons and check
boxes do not exist in the form collection when the form is submitted. This
script will build the SQL statement (great for debugging before activating
the insert or update statment...) One caveat though is to make sure that
your fields allow nulls since you cannot know what is going to be passed. I
allow nulls and set the default value to null.
<CFSET sqlstmt = "INSERT INTO MYTABLEHERE (">
<CFLOOP collection="#form#" item="variable">
<cfif #variable# DOES NOT CONTAIN "FIELDNAMES" AND #variable# DOES NOT
CONTAIN "submit">
<CFIF i LT ((structcount(form)) - 1)>
<CFSET sqlstmt = sqlstmt & "" & variable & ",">
<CFELSE>
<CFSET sqlstmt = sqlstmt & "" & variable & "">
</CFIF>
</cfif>
<cfset i = i + 1>
</CFLOOP>
<CFSET sqlstmt = sqlstmt & ")" & Chr(13) & Chr(10) & "VALUES (">
<CFSET i = 1>
<CFLOOP collection="#form#" item="variable">
<cfif #variable# DOES NOT CONTAIN "FIELDNAMES" AND #variable# DOES NOT
CONTAIN "submit">
<CFIF i LT ((structcount(form)) - 1)>
<CFSET sqlstmt = sqlstmt & "" & structfind(form, variable) & ",">
<CFELSE>
<CFSET sqlstmt = sqlstmt & "" & structfind(form, variable) & "">
</CFIF>
</cfif>
<cfset i = i + 1>
</CFLOOP>
<CFSET sqlstmt = sqlstmt & ")">
<CFOUTPUT>#sqlstmt#</CFOUTPUT>
<!--- Remove these remarks to activate the insert or update query --->
<CFQUERY name="qry_updatestudent" datasource="lsps">
#sqlstmt#
</CFQUERY>
--->
HTH,
Jeff Garza
Webmaster,
Spectrum Astro, Inc.
[EMAIL PROTECTED]
-----Original Message-----
From: Janine Jakim
To: CF-Talk
Sent: 7/13/01 5:43 AM
Subject: Place holder
I have a display page that shows select boxes/input boxes. Depending on
the
subject will depend on if they should fill the box. I have set it so
they
don't see a box if the field should not be filled in.
Problem: On submit an update query is run. My query doesn't like blanks
(loop list update query) and fills in the blanks with the field value of
the
next field.
So this: A ___ Becomes: A 12
B 12 B 19
C 19 C 3
D 3 D
I fixed the problem by adding a select box with no options and puts a .
in
the database as a placeholder. But that is ugly and the user must tab
to/from the field even if the field is useless to them. Any
suggestions. I
think the answer is easy, but it's one of those days that I left my
brain at
home with my gourmet coffee....
Thanks for all/any help
j
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists