Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Multiple Requests on One Form...

Posted on 2004-11-01
4
Medium Priority
?
159 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
Comment
Question by:Lee R Liddick Jr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 5

Expert Comment

by:smaglio81
ID: 12463512
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
ID: 12670253
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:
smaglio81 earned 2000 total points
ID: 12877597
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

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…

618 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