INSERT INTO Sept05Trips VALUES ('#PickupTime#', ..., etc.) [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => BKBK [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 6 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> INSERT INTO Sept05Trips VALUES ('#PickupTime#', ..., etc.) Document Title [allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => MJP22 [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 10 [islastshown] => [isfirstshown] => [attachments] => [allattachments] => ) --> Combine Form Fields - Coldfusion - Advanced Techniques

Combine Form Fields - Coldfusion - Advanced Techniques

I'm doing a small project for a TaxiCab company. I will be collecting Trip data for them. In the collection form I have two fields for selection boxes to keep the time data in a 24 hour clock: PickupTimeHours and PickupTimeMinutes I like to take these two form input and get them to insert into the database into a field called PickupTime. I want the date to look like this 22:40 I've been trying CFSET to concatenate with no luck. I know the solution is simple, but it has alluded me. Can you point me in the right direction? Thanks, ...

Sponsored Links
  1. #1

    Default Combine Form Fields

    I'm doing a small project for a TaxiCab company. I will be collecting Trip
    data for them. In the collection form I have two fields for selection boxes to
    keep the time data in a 24 hour clock:

    PickupTimeHours and PickupTimeMinutes

    I like to take these two form input and get them to insert into the database
    into a field called PickupTime. I want the date to look like this 22:40

    I've been trying CFSET to concatenate with no luck.

    I know the solution is simple, but it has alluded me. Can you point me in
    the right direction?

    Thanks,

    MJP22


    Sponsored Links
    MJP22 Guest

  2. #2

    Default Re: Combine Form Fields

    <cfset PickupTimeHours = "22">
    <cfset PickupTimeMinutes = "40">
    <cfset PickupTime = PickupTimeHours & ":" & PickupTimeMinutes>
    BKBK Guest

  3. #3

    Default Re: Combine Form Fields

    Where does this code go?

    On the page containing the form or on the action page that this form calls?
    Here is the action page.

    <CFINSERT DATASOURCE="YCC_Trips" TABLENAME="Sept05Trips">
    <HTML>
    <HEAD>
    <TITLE>Doent Title</TITLE>
    </HEAD>
    <BODY>
    <cflocation url="http://128.242.115.144/EnterFlags.cfm" addtoken="No">
    </BODY>
    </HTML>

    Also how do I get the form to pass these paramaters into this cfset code?

    Thanks,

    Mark


    MJP22 Guest

  4. #4

    Default Re: Combine Form Fields

    Hi,

    Here is the application:

    http://ycc.taxitripsheets.com/

    Driver: 377
    Pass: 1122

    BTW the driver is me and those are actually the calls I pickup via the
    Computer GPS system in September. How long before they pipe this into directly
    to the IRS :(

    The dirvers need to list their duty shifts, enter their flags and personals,
    and update computer generated calls. This company has a computer dispatch GPS
    system by Mobile Knowlege in Canada.

    We will get a monthly Access table containing approximately 35,000 calls
    involving about 350 drivers. They need to satisify the Police Department and
    the Airport authority.

    MJP22 Guest

  5. #5

    Default Re: Combine Form Fields

    I made an error in the previous post. The URL for the application is:

    http://ycc.taxitripsheet.com/


    MJP22 Guest

  6. #6

    Default Re: Combine Form Fields

    The tag
    <CFINSERT DATASOURCE="YCC_Trips" TABLENAME="Sept05Trips">
    inserts all the form fields directly into the database. However, you wish to
    modify the submitted values before inserting, so you can not use <cfinsert>.
    Use something like this instead:



    <cfif IsDefined("form.hrs")>
    <!--- If we're here, then the form has been submitted --->
    <!--- Perform further validation if necessary--->
    <cfset PickupTimeHours = "#form.hrs#">
    <cfset PickupTimeMinutes = "#form.mins#">
    <cfset PickupTime = PickupTimeHours & ":" & PickupTimeMinutes>
    <CFQUERY DATASOURCE="YCC_Trips" NAME="hrmin">
    INSERT INTO Sept05Trips VALUES ('#PickupTime#', ..., etc.)
    </CFQUERY>
    </cfif>
    <!--- One advantage of cfform over form is: validation --->
    <cfform action="#cgi.script_name#"... etc>
    <cfinput type="text" name="hrs" validate="integer" etc.>
    <cfinput type="text" name="mins" validate="integer" etc.>
    <cfinput type="submit" etc.>
    <cfform>

    BKBK Guest

  7. #7

    Default Re: Combine Form Fields

    Hi BKBK,

    Your code does update the database, but the PickupTime field is blank. Here
    is the actual form:

    ===================>>

    <CFQUERY NAME="GetCalls" DATASOURCE="Ycc_Trips">SELECT * FROM Sept05Trips
    ORDER BY DateEntered DESC</CFQUERY>

    <form action="http://128.242.115.144/post_call.cfm" method="post"
    name="Trips" id="Trips">
    <cfoutput><input type="hidden" name="DriverNumber"
    value="#session.User_ID#"></cfoutput>
    <cfoutput> <input type="hidden" name="DateEntered"
    value="#CreateODBCDateTime(Now())#"></cfoutput>

    <div align="center"><table cellspacing="4" cellpadding="2">
    <tr align="center" valign="bottom">
    <td>Cab<br>Type</td>
    <td>Permit<br>Number<font size="-1"><strong><sup>1</sup></strong></font></td>
    <td>Pickup<br>Date</td>
    <td>Pickup<br>Time</td>
    <td>Pickup<br>Type</td>
    <td>Fare</td>
    </tr>
    <tr align="center" valign="top">
    <td><select name="Company">
    <option value="Yellow Cab" selected>Yellow Cab</option>
    <option value="Checker Cab">Checker Cab</option>
    <option value="Fiesta Cab">Fiesta Cab</option>
    </select>
    </td>
    <td><input type="text" name="PermitNumber" size="4" maxlength="9"></td>
    <td><input type="text" name="TripDate" size="6"><br><cf_calendarpop
    fieldname="TripDate" formname="Trips">&nbsp;&nbsp;&nbsp;<br></td>


    <td>
    <select name="PickupTimeHours">
    <option></option>
    <option value="00">00</option>
    <option value="01">01</option>
    <option value="02">02</option>
    <option value="03">03</option>
    <option value="04">04</option>
    <option value="05">05</option>
    <option value="06">06</option>
    <option value="07">07</option>
    <option value="08">08</option>
    <option value="09">09</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
    <option value="13">13</option>
    <option value="14">14</option>
    <option value="15">15</option>
    <option value="16">16</option>
    <option value="17">17</option>
    <option value="18">18</option>
    <option value="19">19</option>
    <option value="20">20</option>
    <option value="21">21</option>
    <option value="22">22</option>
    <option value="23">23</option>
    <option value="24">24</option>
    </select>
    <select name="PickupTimeMinutes">
    <option></option>
    <option value="00">00</option>
    <option value="01">01</option>
    <option value="02">02</option>
    <option value="03">03</option>
    <option value="04">04</option>
    <option value="05">05</option>
    <option value="06">06</option>
    <option value="07">07</option>
    <option value="08">08</option>
    <option value="09">09</option>
    <option value="10">10</option>
    <option value="11">11</option>
    <option value="12">12</option>
    <option value="13">13</option>
    <option value="14">14</option>
    <option value="15">15</option>
    <option value="16">16</option>
    <option value="17">17</option>
    <option value="18">18</option>
    <option value="19">19</option>
    <option value="20">20</option>
    <option value="21">21</option>
    <option value="22">22</option>
    <option value="23">23</option>
    <option value="24">24</option>
    <option value="25">25</option>
    <option value="26">26</option>
    <option value="27">27</option>
    <option value="28">28</option>
    <option value="29">29</option>
    <option value="30">30</option>
    <option value="31">31</option>
    <option value="32">32</option>
    <option value="33">33</option>
    <option value="34">34</option>
    <option value="35">35</option>
    <option value="36">36</option>
    <option value="37">37</option>
    <option value="38">38</option>
    <option value="39">39</option>
    <option value="40">40</option>
    <option value="41">41</option>
    <option value="42">42</option>
    <option value="43">43</option>
    <option value="44">44</option>
    <option value="45">45</option>
    <option value="46">46</option>
    <option value="47">47</option>
    <option value="48">48</option>
    <option value="49">49</option>
    <option value="50">50</option>
    <option value="51">51</option>
    <option value="52">52</option>
    <option value="53">53</option>
    <option value="54">54</option>
    <option value="55">55</option>
    <option value="56">56</option>
    <option value="57">57</option>
    <option value="58">58</option>
    <option value="59">59</option>
    </select>


    </td>
    <td><select name="TripType">
    <option value="A" selected>Airport</option>
    <option value="D">Dispatch</option>
    <option value="F">Flag/Personal</option>
    <option value="D">Outreach</option>
    </select></td>
    <td>&nbsp;&nbsp;&nbsp;<font size="+1"><strong>$</strong></font> <input
    type="text" name="Fare" size="2"></td>
    </tr>
    <tr align="center" valign="top">

    <td colspan="3">Pickup Address</td>
    <td colspan="2">Airport Origin Zone<font
    size="-1"><strong><sup>2</sup></strong></font></td>
    </tr>
    <tr align="center" valign="top">
    <td colspan="3"><input type="text" name="TripOriginAddress" size="40"
    maxlength="50"></td>
    <td"></td>
    <td colspan="3"><select name="AirportOriginZone">
    <option></option>
    <option value="1">&nbsp;1 - Campbell</option>
    <option value="2">&nbsp;2 - Cupertion</option>

    </select>
    </td>

    </tr>
    <tr align="center" valign="top">

    <td colspan="3">Destination Address</td>
    <td colspan="3">Airport Destination Zone<font size="-1"></td>
    </tr>
    <tr align="center" valign="top">
    <td colspan="3"><input type="text" name="TripDestinationAddress" size="40"
    maxlength="50"></td>

    <td"></td>
    <td colspan="3"><select name="AirportDestinationZone">
    <option></option>
    <option value="1">&nbsp;1 - Campbell</option>
    <option value="2">&nbsp;2 - Cupertion</option>

    </select>
    </td>

    </tr>
    </table></div>
    <br>
    <div align="center"> <input type="submit" value="Enter Trip">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="reset" value="Clear Form">
    </form>

    MJP22 Guest

  8. #8

    Default Re: Combine Form Fields

    >... Your code does update the database, but the PickupTime field is blank
    Could you please let me see the code on your action page, post_call.cfm? In
    particular, the code that inserts into database.



    BKBK Guest

  9. #9

    Default Re: Combine Form Fields

    Here is post_calls.cfm

    <CFINSERT DATASOURCE="YCC_Trips" TABLENAME="Sept05Trips">
    <HTML>
    <HEAD>
    <TITLE>Doent Title</TITLE>
    </HEAD>
    <BODY>
    <cflocation url="http://128.242.115.144/EnterFlags.cfm" addtoken="No">
    </BODY>
    </HTML>


    MJP22 Guest

  10. #10

    Default Re: Combine Form Fields

    Here is post_calls.cfm when I tried your code.

    BTW I don't think anyting was being updated:

    <cfif IsDefined("form.hrs")>
    <!--- If we're here, then the form has been submitted --->
    <!--- Perform further validation if necessary--->
    <cfset PickupTimeHours = "#form.hrs#">
    <cfset PickupTimeMinutes = "#form.mins#">
    <cfset PickupTime = PickupTimeHours & ":" & PickupTimeMinutes>
    <CFQUERY DATASOURCE="YCC_Trips" NAME="hrmin">
    INSERT INTO Sept05Trips VALUES ('#PickupTime#', ..., etc.)
    </CFQUERY>
    </cfif>
    <HTML>
    <HEAD>
    <TITLE>Doent Title</TITLE>
    </HEAD>
    <BODY>
    <cflocation url="http://128.242.115.144/EnterFlags.cfm" addtoken="No">
    </BODY>
    </HTML>

    MJP22 Guest

  11. #11

    Default Re: Combine Form Fields

    INSERT INTO Sept05Trips VALUES ('#PickupTime#', ..., etc.)

    The source of the error immediately jumps out at you. You forgot
    to fill in the column names of your database-table in place of , ..., etc.


    BKBK Guest

  12. #12

    Default Re: Combine Form Fields

    INSERT INTO Sept05Trips VALUES ('#PickupTime#', ..., etc.)

    The source of the error immediately jumps out at you. You forgot to fill in
    the
    values corresponding to the other columns of your database-table in the place
    where I write , ..., etc.

    For example, I expect your table's columns to be

    dateEntered
    PickupTime
    permitNumber
    tripDate
    tripType
    tripOriginAddress
    AirportOriginZone
    TripDestinationAddress
    AirportDestinationZone

    You would then do something like

    <CFQUERY DATASOURCE="YCC_Trips" NAME="hrmin">
    INSERT INTO Sept05Trips VALUES
    (#form.dateEntered#,'#PickupTime#','#form.permitNu mber#','#form.tripDate#','#for
    m.tripType#','#form.tripOriginAddress#','#form.Air portOriginZone#','#form.TripDe
    stinationAddress#','#form.AirportDestinationZone#' )
    </CFQUERY>


    BKBK Guest

  13. #13

    Default Re: Combine Form Fields

    Hi BKBK,

    I'm very close to getting this to wrok. The values are being passed, but I
    get the following error:

    Error Executing Database Query.
    [Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft
    Access Driver] Number of query values and destination fields are not the same.

    The error occurred in D:\webhosting\YCC_TripSheet\post_call.cfm: line 8

    6 : <cfset PickupTime = PickupTimeHours & ":" & PickupTimeMinutes>
    7 : <CFQUERY DATASOURCE="YCC_Trips" NAME="hrmin">
    8 : INSERT INTO Sept05Trips VALUES ('#form.Fare#', '#form.Company#',
    '#form.DriverNumber#', #form.dateEntered#, '#PickupTime#',
    '#form.permitNumber#', '#form.tripDate#', '#form.tripType#',
    '#form.tripOriginAddress#', '#form.AirportOriginZone#',
    '#form.TripDestinationAddress#', '#form.AirportDestinationZone#')
    9 : </CFQUERY>
    10 : </cfif>




    --------------------------------------------------------------------------------

    SQL INSERT INTO Sept05Trips VALUES ('44.75', 'Yellow Cab', '377', {ts
    '2005-10-31 14:43:30'}, '21:04', '3344', '10/20/2005', 'A', 'Garden City', '5',
    'Los Gatops Lodge', '4')
    DATASOURCE YCC_Trips
    VENDORERRORCODE -3520
    SQLSTATE 21S01

    =====================================

    In the Insert Into statement, do I need the same number of values as the
    number of fields in the table? If so, how do I handle the ID field (Primary
    Key - Auto Number)? Here is a list of all the fields in the table:

    ID - Primary Key - Auto Number
    Company - text
    TripDate - text
    PermitNumber - text
    DriverNumber - text
    AirportAccess - text
    TripType - text
    PickupTime - text
    AirportOriginZone - text
    TripOriginAddress - text
    AirportDestinationZone - text
    Fare - Text
    DateEntered - Date/Time


    Thanks for the help . . .

    MJP22 Guest

  14. #14

    Default Re: Combine Form Fields

    The list of table fields also included TripDestinationAddress - text, which I negelected to include in the list above.

    -Mark-
    MJP22 Guest

  15. #15

    Default Re: Combine Form Fields

    I have all fields included in the insert statement and in the same order as in
    the database. It looks like it will work, but I do not know what to do witht
    he ID (Primary Key autonumber) field.

    This table contains around 35,000 records. The ID field is used to update
    computer dispatched calls.

    Do I need to create a sepearte table to receive new calls and import or join
    this table with already existing call table?

    Thanks,

    -Mark-



    MJP22 Guest

  16. #16

    Default Re: Combine Form Fields

    This table contains around 35,000 records. The ID field is used to update
    computer dispatched calls.
    Do I need to create a sepearte table to receive new calls and import or join
    this table with already existing call table?

    No, nothing that complicated. If you're using the automatically generated
    tion ID, which I assume
    you are, then you only have to use a different version of the INSERT query.
    One which inserts data for
    every column, except the ID column. The MS Access database engine will insert
    the new ID automatically.




    <CFQUERY DATASOURCE="YCC_Trips" NAME="hrmin">
    INSERT INTO Sept05Trips
    (fare,company,dateEntered,PickupTime,permitNumber, tripDate,tripType,tripOriginAd
    dress,AirportOriginZone,TripDestinationAddress,Air portDestinationZone)
    VALUES ('#form.Fare#', '#form.Company#', '#form.DriverNumber#',
    #form.dateEntered#, '#PickupTime#', '#form.permitNumber#', '#form.tripDate#',
    '#form.tripType#', '#form.tripOriginAddress#', '#form.AirportOriginZone#',
    '#form.TripDestinationAddress#', '#form.AirportDestinationZone#')
    </CFQUERY>

    BKBK Guest

  17. #17

    Default Re: Combine Form Fields

    Thanks BKBK.

    Before I got your message I setup a seperate table, makikng the application
    run a bit faster. It will be a simple matter to import the new table into the
    old at the end of the month when the company needs to generate an Excel table
    for the Airport.

    I learned a lost in the last two days. Thanks . . ..

    MJP22 Guest

  18. #18

    Default Re: Combine Form Fields

    Good luck with the setup, MJP22.


    BKBK Guest

Similar Threads

  1. Dynamically Adding Form Fields to CF Flash Form
    By craigkaminsky in forum Coldfusion Flash Integration
    Replies: 0
    Last Post: December 15th, 01:07 AM
  2. add form fields ?
    By liz_liverman@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 2
    Last Post: July 28th, 04:45 PM
  3. Populate form values based on previous same form fields
    By Rizyak in forum PHP Development
    Replies: 2
    Last Post: June 11th, 04:27 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •