#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    14
    Rep Power
    0

    Sumbit output of form with multiple records (Help)


    I have looked far and wide without success for the answer.
    I have a form that outputs devices to the end user. There is a checkbox that the user can click. Sometimes there are two checkboxes. The form is used to display the Telecom devices a user possesses that our telecom department shows that these devices are assigned to the end user. If the end user has turned in those devices and the devices still shows the end user still has possession. The end user can check the checkbox(s) and an email will be generated to tell Telecom that he/she has already turned in the items.

    My form is as follows:
    Code:
    <form action="#CGI.SCRIPT_NAME#?v=#v#" method="post" >
    <table">
    <tr>
    <th>Device Type</th>
    <th>Number</th>
    <th>Model</th>
    <th>Serial Num</th>
    <th>Date Assigned</th>
    <th>Agreement Form</th>
    <th>View</th>
    <th>Not Assigned</th>
    /tr>
    <input type="hidden" id="publicFunc" name="publicFunc" value="ToTelecom" />
    <cfloop query="myDevices">
    <input type="hidden" name="DeviceType" value="#mydevices.deviceName#" /> 
    <input type="hidden" name="phoneNumber" value="#mydevices.phonenumber#" /> 
    <input type="hidden" name="modelNumber" value="#mydevices.modelName#" /> 
    <input type="hidden" name="SerialNumber" value="#mydevices.serialNum#" />
    <input type="hidden" name="dateAssigned" value="#dateformat(myDevices.IssueDate, 'mm/dd/yyyy')#" /> 
    <tr>
    <td style="text-align:left;">#mydevices.deviceName#</td>
    <td>#phone#</td>
    <td>#mydevices.modelName#</td>
    <td>#mydevices.serialNum#</td>
    <td>#dateformat(myDevices.IssueDate, 'mm/dd/yyyy')#</td>
    <td><input type="checkbox" id="notAssigned[]" value="#mydevices.deviceName#" name="notAssigned" /></td>
    </tr>
    
    </cfloop>
    <tr>
    <td><input type="submit" value="Submit to Telecom"  name="Submit"  /></td>
    </tr>
    </table
    On the action page, I want to email the information that the end user checked on the checkbox. I have it working for one checkbox but if a user checks both boxes the output comes out like this.
    <cfdump var="#form#">
    DATEASSIGNED 07/06/2011,04/06/2011
    DEVICETYPE Air Card,Blackberry
    FIELDNAMES PUBLICFUNC,DEVICETYPE,PHONENUMBER,MODELNUMBER,SERIALNUMBER,DATEASSIGNED,NOTASSIGNED,SUBMIT
    MODELNUMBER Sierra 250U,Blackberry Bold
    NOTASSIGNED Air Card,Blackberry
    PHONENUMBER 6198462907,6198226032
    PUBLICFUNC ToTelecom
    SERIALNUMBER 09613997780 ,268435459706096635
    SUBMIT Submit to Telecom

    If you noticed, such as the modelnumber it shows two items, a Sierra 250U and a Blackberry separated by a coma.

    How do I separate all the fields to output as
    Fieldname names
    #DeviceType# #Modelnumber# #phonenumber# etc.
    #DeviceType# #Modelnumber# #phonenumber# etc.

    How do I split each variable into two separate items?

    TIA
    Mike
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    14
    Rep Power
    0
    I figured it out. You have to used the ListToArray function and then use another cfloop to output the format in a readable manner. Here is the example

    <CFLOOP index="LoopCount" from="1" to="#ListLen(form.devicetype)#">
    <cfset aDeviceType = #ListToArray(form.DeviceType, ",")#>
    <cfset aModelNumber = #ListToArray(form.ModelNumber, ",")#>
    <cfset aPhoneNumber = #ListToArray(Form.PhoneNumber, ",")#>
    <cfset aSerialNumber = #ListToArray(Form.SerialNumber, ",")#>
    <cfset aDateAssigned = #ListToArray(Form.DateAssigned, ",")#>
    </CFLOOP>

    <cfloop index="x" from="1" to="#ListLen(form.devicetype)#">
    #aDeviceType[x]# #aModelNumber[x]# #aPhoneNumber[x]# #aSerialNumber[x]# #aDateAssigned[x]#<br />
    </cfloop>

    Mike

    Originally Posted by mevasquez
    I have looked far and wide without success for the answer.
    I have a form that outputs devices to the end user. There is a checkbox that the user can click. Sometimes there are two checkboxes. The form is used to display the Telecom devices a user possesses that our telecom department shows that these devices are assigned to the end user. If the end user has turned in those devices and the devices still shows the end user still has possession. The end user can check the checkbox(s) and an email will be generated to tell Telecom that he/she has already turned in the items.

    My form is as follows:
    Code:
    <form action="#CGI.SCRIPT_NAME#?v=#v#" method="post" >
    <table">
    <tr>
    <th>Device Type</th>
    <th>Number</th>
    <th>Model</th>
    <th>Serial Num</th>
    <th>Date Assigned</th>
    <th>Agreement Form</th>
    <th>View</th>
    <th>Not Assigned</th>
    /tr>
    <input type="hidden" id="publicFunc" name="publicFunc" value="ToTelecom" />
    <cfloop query="myDevices">
    <input type="hidden" name="DeviceType" value="#mydevices.deviceName#" /> 
    <input type="hidden" name="phoneNumber" value="#mydevices.phonenumber#" /> 
    <input type="hidden" name="modelNumber" value="#mydevices.modelName#" /> 
    <input type="hidden" name="SerialNumber" value="#mydevices.serialNum#" />
    <input type="hidden" name="dateAssigned" value="#dateformat(myDevices.IssueDate, 'mm/dd/yyyy')#" /> 
    <tr>
    <td style="text-align:left;">#mydevices.deviceName#</td>
    <td>#phone#</td>
    <td>#mydevices.modelName#</td>
    <td>#mydevices.serialNum#</td>
    <td>#dateformat(myDevices.IssueDate, 'mm/dd/yyyy')#</td>
    <td><input type="checkbox" id="notAssigned[]" value="#mydevices.deviceName#" name="notAssigned" /></td>
    </tr>
    
    </cfloop>
    <tr>
    <td><input type="submit" value="Submit to Telecom"  name="Submit"  /></td>
    </tr>
    </table
    On the action page, I want to email the information that the end user checked on the checkbox. I have it working for one checkbox but if a user checks both boxes the output comes out like this.
    <cfdump var="#form#">
    DATEASSIGNED 07/06/2011,04/06/2011
    DEVICETYPE Air Card,Blackberry
    FIELDNAMES PUBLICFUNC,DEVICETYPE,PHONENUMBER,MODELNUMBER,SERIALNUMBER,DATEASSIGNED,NOTASSIGNED,SUBMIT
    MODELNUMBER Sierra 250U,Blackberry Bold
    NOTASSIGNED Air Card,Blackberry
    PHONENUMBER 6198462907,6198226032
    PUBLICFUNC ToTelecom
    SERIALNUMBER 09613997780 ,268435459706096635
    SUBMIT Submit to Telecom

    If you noticed, such as the modelnumber it shows two items, a Sierra 250U and a Blackberry separated by a coma.

    How do I separate all the fields to output as
    Fieldname names
    #DeviceType# #Modelnumber# #phonenumber# etc.
    #DeviceType# #Modelnumber# #phonenumber# etc.

    How do I split each variable into two separate items?

    TIA
    Mike
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Posts
    14
    Rep Power
    0

    Sumbit output of form with multiple records (Help)


    I figured it out. You have to used the ListToArray function and then use another cfloop to output the format in a readable manner. Here is the example

    <CFLOOP index="LoopCount" from="1" to="#ListLen(form.devicetype)#">
    <cfset aDeviceType = #ListToArray(form.DeviceType, ",")#>
    <cfset aModelNumber = #ListToArray(form.ModelNumber, ",")#>
    <cfset aPhoneNumber = #ListToArray(Form.PhoneNumber, ",")#>
    <cfset aSerialNumber = #ListToArray(Form.SerialNumber, ",")#>
    <cfset aDateAssigned = #ListToArray(Form.DateAssigned, ",")#>
    </CFLOOP>

    <cfloop index="x" from="1" to="#ListLen(form.devicetype)#">
    #aDeviceType[x]# #aModelNumber[x]# #aPhoneNumber[x]# #aSerialNumber[x]# #aDateAssigned[x]#<br />
    </cfloop>

    Mike

    Originally Posted by mevasquez
    I have looked far and wide without success for the answer.
    I have a form that outputs devices to the end user. There is a checkbox that the user can click. Sometimes there are two checkboxes. The form is used to display the Telecom devices a user possesses that our telecom department shows that these devices are assigned to the end user. If the end user has turned in those devices and the devices still shows the end user still has possession. The end user can check the checkbox(s) and an email will be generated to tell Telecom that he/she has already turned in the items.

    My form is as follows:
    Code:
    <form action="#CGI.SCRIPT_NAME#?v=#v#" method="post" >
    <table">
    <tr>
    <th>Device Type</th>
    <th>Number</th>
    <th>Model</th>
    <th>Serial Num</th>
    <th>Date Assigned</th>
    <th>Agreement Form</th>
    <th>View</th>
    <th>Not Assigned</th>
    /tr>
    <input type="hidden" id="publicFunc" name="publicFunc" value="ToTelecom" />
    <cfloop query="myDevices">
    <input type="hidden" name="DeviceType" value="#mydevices.deviceName#" /> 
    <input type="hidden" name="phoneNumber" value="#mydevices.phonenumber#" /> 
    <input type="hidden" name="modelNumber" value="#mydevices.modelName#" /> 
    <input type="hidden" name="SerialNumber" value="#mydevices.serialNum#" />
    <input type="hidden" name="dateAssigned" value="#dateformat(myDevices.IssueDate, 'mm/dd/yyyy')#" /> 
    <tr>
    <td style="text-align:left;">#mydevices.deviceName#</td>
    <td>#phone#</td>
    <td>#mydevices.modelName#</td>
    <td>#mydevices.serialNum#</td>
    <td>#dateformat(myDevices.IssueDate, 'mm/dd/yyyy')#</td>
    <td><input type="checkbox" id="notAssigned[]" value="#mydevices.deviceName#" name="notAssigned" /></td>
    </tr>
    
    </cfloop>
    <tr>
    <td><input type="submit" value="Submit to Telecom"  name="Submit"  /></td>
    </tr>
    </table
    On the action page, I want to email the information that the end user checked on the checkbox. I have it working for one checkbox but if a user checks both boxes the output comes out like this.
    <cfdump var="#form#">
    DATEASSIGNED 07/06/2011,04/06/2011
    DEVICETYPE Air Card,Blackberry
    FIELDNAMES PUBLICFUNC,DEVICETYPE,PHONENUMBER,MODELNUMBER,SERIALNUMBER,DATEASSIGNED,NOTASSIGNED,SUBMIT
    MODELNUMBER Sierra 250U,Blackberry Bold
    NOTASSIGNED Air Card,Blackberry
    PHONENUMBER 6198462907,6198226032
    PUBLICFUNC ToTelecom
    SERIALNUMBER 09613997780 ,268435459706096635
    SUBMIT Submit to Telecom

    If you noticed, such as the modelnumber it shows two items, a Sierra 250U and a Blackberry separated by a coma.

    How do I separate all the fields to output as
    Fieldname names
    #DeviceType# #Modelnumber# #phonenumber# etc.
    #DeviceType# #Modelnumber# #phonenumber# etc.

    How do I split each variable into two separate items?

    TIA
    Mike
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    If you can guarantee that the order they display is always the same as the order they'll be processed on the server, you can just split the list using the list functions.

    The better way would be to differentiate the form field names so you can tell which ones go with which device. You can do this by appending the device ID, something like:

    <input type="checkbox" id="notAssigned[]" value="#mydevices.deviceName#" name="notAssigned_#myDevices.deviceId#" />

    (or whatever your device ID column name is).

    I wrote a CFC that will do this pretty well but I haven't updated it in a while so use at your own risk. That said I think it should work for you. http://formutils.riaforge.org/

IMN logo majestic logo threadwatch logo seochat tools logo