Solved

Multiple Requests on One Form...

Posted on 2004-11-01
157 Views
Last Modified: 2013-12-24
I'm not even sure how to ask the question, but here is what I am trying to do.  I  have a form which requests time off.  The current form allows for one date per request.  What I am trying to do is create the form to allow for multiple days so when the user submits the request, whether they request one day or 5 days it populates the dbase once or 5 times (whichever is the case) so that the requests may be processed.  Upon submit, the request submits to an Access dbase.

The form currently looks something like this:

<CFFORM NAME="timeoff" ACTION="post.cfm" METHOD="POST">
<table cellspacing="2" cellpadding="2" border="2" bgcolor="#333333" bordercolor="#6699CC">
<tr bordercolor="#333333">
    <td colspan="2" width="200" nowrap class="normalsilver">&nbsp;&nbsp;&nbsp;<b>Your Name:</b></td>
    <td colspan="2" width="300" nowrap class="normalsilver">
      <cfoutput>
            <select name="#EmployeeID#">#SortName#</select>
      </cfoutput>
     </td>
</tr>
<tr bordercolor="#333333">
    <td colspan="2" width="200" nowrap class="normalsilver">&nbsp;&nbsp;&nbsp;<b>Date Requested:</b></td>
    <td nowrap class="normalsilver">
            <INPUT TYPE="text" NAME="DateRequested" SIZE="14" value="">
            <a onclick="javascript: popUpCalendar(this, DateRequested, 'mm/dd/yyyy', -1, -1);" onMouseOver="style.cursor='hand';" onMouseOut="style.cursor='default';">
          <img src="../images/popupcalendar/calendar.gif" align="absmiddle" border="0">
            </a>
      </td>
    <td class="tinywhite">Now accepting requests prior to and including <b><CFOUTPUT>#DateFormat(CreateODBCDate(now()+90), "MM/DD/YYYY")#</CFOUTPUT></b></td>
</tr>
<tr bordercolor="#333333">
    <td colspan="2" width="200" nowrap class="normalsilver">&nbsp;&nbsp;&nbsp;<b>Reason:</b></td>
    <td colspan="2" width="300" nowrap class="normalsilver">
            <select name="reason">
                        <option value="">
                  <cfoutput query="qsel_reasons">
                        <option value="#reason#">#reason_name#
                  </cfoutput>
            </select>
      </td>
</tr>
<tr bordercolor="#333333">
    <td colspan="2" width="200" nowrap class="normalsilver">&nbsp;&nbsp;&nbsp;<b>Shift:</b></td>
    <td colspan="2" width="300" nowrap class="normalsilver">
            <select name="shift">
                  <option value=""></option>
                  <option value="1st">1st Shift</option>
                  <option value="2nd">2nd Shift</option>
            </SELECT>
      </td>
</tr>
<tr bordercolor="#333333">
    <td colspan="2" width="200" nowrap class="normalsilver">&nbsp;&nbsp;&nbsp;<b>All Day:</b></td>
    <td width="75" nowrap class="normalsilver">
            <b>Yes</b><INPUT onClick="MM_showHideLayers('Layer1','','hide')" type="radio" value="Yes" name="allday" checked>
      </td>
    <td width="75" nowrap class="normalsilver">
            <b>No</b><INPUT onClick="MM_showHideLayers('Layer1','','show')" type="radio" value="No" name="allday">
      </td>
</tr>
<tr bordercolor="#333333">
    <td colspan="4" width="500" height="60" nowrap class="normalsilver">
      <!-- The Values for teh textBoxes can be decided at run time / predefined using query -->
    <DIV id="Layer1" style="Z-INDEX: 1; LEFT: 306px; VISIBILITY: hidden; WIDTH: 200px; POSITION: absolute; TOP: 471px; HEIGHT: 50px">
         <TABLE cellSpacing="0" cellPadding="0" border="0" bgcolor="#333333">
              <TBODY>
                   <TR>
    <td width="100" nowrap class="normalsilver"><b>Time Start:</b></td>
    <td width="200" nowrap class="normalsilver">
      <select name="timestart">
            <option value="">
            <cfoutput query="qsel_time">
                  <option value="#military#">#regular#
            </cfoutput>
      </select>      
      </td>
                   </TR>
              </TBODY>
         </TABLE>
         <TABLE cellSpacing="0" cellPadding="0" border="0" bgcolor="#333333">
              <TBODY>
                   <TR>
    <td width="100" nowrap class="normalsilver"><b>Duration:</b></td>
    <td width="200" nowrap class="normalsilver">
      <select name="duration">
            <option value="">
            <cfoutput query="qsel_duration">
                  <option value="#duration#">#actual#
            </cfoutput>
      </select>            
      </td>
                   </TR>
              </TBODY>
         </TABLE>
    </DIV>
      </td>
</tr>
<tr bordercolor="#333333">
    <td colspan="4" width="500" height="50" nowrap class="normalsilver">
      <input type="hidden" name="SubmitTime" value="<cfoutput>#CreateODBCDateTime(DateAdd("h",3, Now()))#</cfoutput>">
      <DIV align="center">
            <INPUT type="submit" value="Submit" class="subheadblue">&nbsp;&nbsp;
            <INPUT type="Reset" value="Clear Form" class="subheadblue">
      </div>
      </td>
</tr>
</table>
</CFFORM>

Any suggestions on how I accomplish this?
0
Question by:Lee R Liddick Jr
    3 Comments
     
    LVL 5

    Expert Comment

    by:smaglio81
    right now you have a text input field for the date. You can change that to a select input field and populate it with a number of upcoming dates. Then you can allow the user to select multiple entries within the select input field. An example might be,

    <cfset sDate = now() />
    You may select a range of dates by selecting the first date and shift-clicking the final date:<br />
    <select multiple="multiple" size="10" name="dateRequested">

          <!--- loop over the next 3 months worth of dates --->
          <cfloop index="i" from="0" to="90">
          
                <!--- generate a date --->
                <cfset loopDate = DateFormat( DateAdd( "d", i, sDate ), "mm/dd/yyyy" ) />
                
                <!--- add the date to the list --->
                <cfoutput>
                      <option value="#loopDate#">#loopDate#</option>
                </cfoutput>
          </cfloop>
    </select>

    Then you would be presented with a list of dates within your action page, "post.cfm". You would need to rewrite the query to loop over the list of dates and perform an insert sql query for each date selected.

    HTH,

    Steven
    0
     

    Author Comment

    by:Lee R Liddick Jr
    Wow...I forgot I posted this question.  Steven...you mentioned that the shift-clicking on the dates will populate multiple dates in the field...but does the cntrl-click work as well if they want to select say 11/26 and 11/29?

    Also...I'm not sure how I would rewrite the query to loop over the dates and do an insert into the table for each date selected.  Is there a site anywhere you would deem helpful on this topic?

    Thanks again...and my apologies for the delay...

    lrl
    0
     
    LVL 5

    Accepted Solution

    by:
    Yeah, you can use Control-Click to select a group of individual dates.

    When the form is submitted, the action page will recieve the data within the variable form.dateRequested as a comma deliminated list of dates. In order to look through the dates, you can use another cfloop.

    <cfloop index="date" list="#form.dateRequested#">

          <cfquery datasource="#dsn#">
               INSERT INTO <tblName>
                       ( personID, submittedDate, dateRequested )
               VALUES (
                        <cfqueryparam cfsqltype="cf_sql_int" value="#form.personID#" />,
                        getDate(),
                        <cfqueryparam cfsqltype="cf_sql_date" value="#date#" />
                )
          </cfquery>

    </cfloop>


    Except you would change the column names and values entered to be what works with your database.

    I don't really know of a good way in Coldfusion to send over a list of entries into a database. So, for now I use repetitions insert statements to get the job done.

    Steven
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: Foundations of Front-End Development

    Jump-start a lucrative career in front-end web development, with zero previous coding experience required. This course covers the basic programming concepts and languages required for creating engaging websites from scratch.

    Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
    Article by: kevp75
    Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
    This video Micro Tutorial is the second in a two-part series that shows how to create and use custom scanning profiles in Nuance's PaperPort 14.5 (http://www.experts-exchange.com/articles/17490/). But the ability to create custom scanning profiles a…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now