I have an interesting/challenging question in which I would really appreciate some guidance. I recently created a form like so:
Essentially, the user selects what type of fruit they have per state. If they are currently out of stock of a particular fruit, but it is a fruit they carry, then they enter in the "Dates Unavail" column the days that the fruit is not available at that location. This list shown is for the weekend, and broken down by district.
My database looks like so:
district_uid = The district
dow_uid = 1 for Weekend, 2 for Weekday
state_uid = The states
fruid_uid = The fruits
CA_unavail = Represents the text boxes for the dates_unavail (same for FL_unavail, etc)
There are also separate tables that define the particular states, fruits, districts, and dow.
fruit_uid | fruit_description
1 | apple
2 | orange
3 | banana
Ok, so part of this is actually a project I've completed in the past. I was able to get all the checkboxes to insert into the database; however, was recently tasked add the dates_unavail textboxes to each section. This is the part I am having troubles with.
Here is how I got the checkboxes to work:
<cfset qAppleWknd = QueryNew("fruit, UID")>
<cfset QueryAddRow(qAppleWknd, 3)>
<cfset QuerySetCell(qAppleWknd, "fruit", "1_1_1", 1)>
<cfset QuerySetCell(qAppleWknd, "UID", "1", 1)>
<cfset QuerySetCell(qAppleWknd, "fruit", "1_2_1", 2)>
<cfset QuerySetCell(qAppleWknd, "UID", "2", 2)>
<cfset QuerySetCell(qAppleWknd, "fruit", "1_3_1", 3)>
<cfset QuerySetCell(qAppleWknd, "UID", "3", 3)>
This essentially creates a query to define each checkbox. So, 1_1_1 represents dow_uid, state_uid, fruit_uid. Therefore, this would be 1 = weekend, 1 = florida, 1 = apple.
Here's the ColdFusion code for the table:
<td><input type="checkbox" name="fruit" value="#qAppleWknd.fruit#" /></td>
Again, if the user chose the first checkbox, the value outputted to the action page will be: 1_1_1.
Here is how the code gets inserted into the database:
<cfloop list="#form.fruit#" index="box" delimiters=",">
<cfset dow = listGetAt(box, 1, "_")>
<cfset state = listGetAt(box, 2, "_")>
<cfset fruit = listGetAt(box, 3, "_")>
<cfquery name="qInsertFruit" datasource="#database#" username="#dbid#" password="#dbpass#">
INSERT INTO fruit (
So, I know this may not be the ideal way to code this (this project was initially done years ago), but now I'm trying to get the textboxes (dates_unavil) to work. I hope I don't have to recode a whole lot of stuff, but please give any advice you can.
Thanks in advance. Sorry for this being a long one, just trying to make sure you guys understand it.