Basically, I have a form that generates a certain number of "types of publications" depending on "departments" input before someone is filling out this form. (Department specific publication types that are recognized.) There are a couple of fields that go with each publication type...(they are the same fields, so each type will have ...let say 3 fields..) I have a loop that reads this data and puts it into the database. However, if one of the fields are not filled out the value for that particular field is completely skipped thus throwing off the input of data.
Example: User has three fields and these three fields are repeated three times. The user fills out three in the first row two in the second row and three again in the third row. So:
- First field array: 1, 1, 1
- Second field array: 1, 1
- Third field array: 1, 1, 1
I need to figure out a way to mark that empty field in the second field array so it will appear in the list. I could set default values to the fields, but someone could easily delete that data and in name/ title fields it would seem tacky to have "None" or something...
Any Ideas?
Edit: Code Snippet (Note: I cut out all the unimportant style type things...)
<cfoutput query = "getType_PUB">
Publications: #rName# <br />
<input type = "hidden" name = "scholarActivities" value = "#rName#" />
<input type="text" name="inpress09" size = "8"/><br />
<input type="text" name="published09" size = "8"/><br />
<input type="text" name="published08" size = "8"/><br />
<input type="text" name="published07" size = "8"/><br />
</cfoutput>
<cfoutput><input type = "hidden" name = "recordcountPub" value = "#getType_PUB.recordcount#" /></cfoutput>
//////////////DB/////////////
<cfif #form.recordcountPUB# EQ 1>
<cfquery name = "insertSActivities" datasource="cas_evaluation">
INSERT INTO scholar_publications (faculty, scholarActivities, submit09, inpress09, published09, published08, published07)
VALUES ( '#form.name#', '#form.scholarActivities#', '#form.submit09#', '#form.inpress09#', '#form.published09#', '#form.published08#', '#form.published07#')
</cfquery>
<cfelse>
<cfloop from="1" to="#form.recordcountPUB#" index="i">
<cfquery name = "insertSActivities" datasource="cas_evaluation">
INSERT INTO scholar_publications (faculty, scholarActivities, submit09, inpress09, published09, published08, published07)
VALUES ( '#form.name#', '#ListGetAt(form.scholarActivities, i, ',')#', '#ListGetAt(form.submit09, i, ',')#', '#ListGetAt(form.inpress09, i, ',')#', '#ListGetAt(form.published09, i, ',')#', '#ListGetAt(form.published08, i, ',')#', '#ListGetAt(form.published07, i, ',')#')
</cfquery>
</cfloop>
</cfif>