Solved

An Edit Form with Select DD Boxes

Posted on 2004-09-23
5
152 Views
Last Modified: 2013-12-24
I have a form that features Select boxes that the user completes and submits and it populates an Access dbase.  What I am needing to do now, is build an Edit Form but I've never done an Edit Form using Select Boxes (just Input).  I know my code for the Edit form for just the Input boxes looks like this:

<INPUT TYPE="text" Name="LastName"
     <CFIF to_do IS "edit">
          VALUE="<CFOUTPUT>#empfile.LastName#</CFOUTPUT>"
     </CFIF>
>

But what would a Select type look like...if one of my Select Boxes looked like this:

<select name="reasonid" class="tinyblue">
     <option value="">
     <cfoutput query="qsel_reasons">
     <option value="#ReasonID#">#reasonname#
     </cfoutput>
</select>
0
Comment
Question by:Lee R Liddick Jr
  • 3
  • 2
5 Comments
 
LVL 14

Expert Comment

by:Renante Entera
ID: 12140281
Hello leerljr68!

A correction, you forgot to enclosed the <option> tag.  Lacking "</option>".

Kindly take a look at this code :

<cfparam name="form.reasonid" default="">

<!--- I am assuming that you submit to the same page --->
<form name="form1" action="" method="post">
  <select name="reasonid" class="tinyblue">
     <option value=""></option>
     <cfoutput query="qsel_reasons">
     <option value="#ReasonID#" <cfif form.reasonid eq ReasonID>selected</cfif>>#reasonname#</option>
     </cfoutput>
  </select>
  <input type="submit" value="Submit">
</form>

Try running this code and I do hope that you can get an idea from this one.

In addition to that, kindly elaborate what you really expect to come up.  What would be the result that you want???


Goodluck!
eNTRANCE2002 :-)
0
 

Author Comment

by:Lee R Liddick Jr
ID: 12140604
No, I am posting to another page.

I have a page emp_corrective-action.cfm that lists all the employee's corrective action...when the user clicks on the CAID (corrective action id) of a particular line it takes them to a page emp_ca-edit.cfm which should have a form showing all the information for that particular corrective action.

So, say the user clicks on CAID 100 for Employee #1234567, then it will direct them to a page emp_ca-edit.cfm?CAID=100&EmpID=1234567 and the page should display a form like this, but should be populated with the information associated with CAID 100.

<CFIF ISDefined("CAID")>
      <CFSET to_do="edit">
</CFIF>
<CFIF to_do IS "edit">
<CFQUERY datasource="myds" name="caedit" blockfactor="100">
      SELECT *
      FROM tbl_correctiveaction, tbl_employees
      WHERE tbl_correctiveaction.EmployeeID=tbl_employees.EmployeeID
      AND tbl_correctiveaction.CAID = #CAID#
</CFQUERY>
</CFIF>
<CFFORM NAME="caedit" ACTION="emp_ca-update.cfm" METHOD="POST" onsubmit="return v.exec()">

<table bgcolor="336699" width="95%" cellspacing="2" cellpadding="2" border="0">
<tr>
<td class="smallsilver" align="right" valign="middle" id="t_caid">
Corrective Action ID:<span class="smallred">*</span>
</td>
<td>
<cfoutput query="qselcaedit">
<INPUT TYPE="Text" NAME="caid" SIZE="10" class="tinysilver" value="#CAID#" disabled>
</cfoutput>
</td>
</tr>
<tr>
<td class="smallsilver" align="right" valign="middle" id="t_reason">
Reason:<span class="smallred">*</span>
</td>
<td>
<select name="reasonid" class="tinyblue">
<option value=""></option>
<cfoutput query="qsel_reasons">
<option value="#ReasonID#">#type# - #reasonname#</option>
</cfoutput>
</select>
</td>
</tr>
<tr>
<td class="smallsilver" align="right" valign="middle" id="t_level">
Level:<span class="smallred">*</span>
</td>
<td>
<select name="levelid" class="tinyblue">
<option value=""></option>
<cfoutput query="qsel_level">
<option value="#LevelID#">#levelID# - #levelname#</option>
</cfoutput>
</select>
</td>
</tr>
<tr>
<td class="smallsilver" align="right" valign="middle" id="t_effect_date">
Effective<br>Date:<span class="smallred">*</span>
</td>
<td>
<INPUT TYPE="text" NAME="effect_date" class="tinyblue" SIZE="15" maxlength="10"
<CFIF to_do IS "edit">
value="<CFOUTPUT>#DateFormat(qselcaedit.effect_date, 'mm/dd/yyyy')#</CFOUTPUT>"
<a onclick="javascript: popUpCalendar(this, effect_date, 'mm/dd/yyyy', -1, -1);" onMouseOver="style.cursor='hand';" onMouseOut="style.cursor='default';"></a>                                    
</CFIF>
</td>
</tr>
<tr>
<td class="smallsilver" align="right" valign="middle" id="t_end_date">
End/Projected<br>Review Date:<span class="smallred">*</span>
</td>
<td>
<INPUT TYPE="text" NAME="end_rev_date" class="tinyblue" SIZE="15" maxlength="10"
<CFIF to_do IS "edit">
value="<CFOUTPUT>#DateFormat(qselcaedit.end_rev_date, 'mm/dd/yyyy')#</CFOUTPUT>"
<a onclick="javascript: popUpCalendar(this, end_rev_date, 'mm/dd/yyyy', -1, -1);" onMouseOver="style.cursor='hand';" onMouseOut="style.cursor='default';"></a>                                    
</CFIF>
</td>
</tr>
<tr>
<td class="smallsilver" align="right" valign="middle" id="t_notes">
Notes:
</td>
<td>
<textarea name="notes" cols="40" rows="10" class="tinyblue"></textarea>
</td>
</tr>
<tr>
<td class="tinysilver" align="left" valign="middle" colspan="2">
<font color="Red">*</font> = Required fields
</td>
</tr>
<tr>
<td align="center" valign="middle" colspan="2">
<input type="hidden" name="CAID" value="<cfoutput query="qselcaedit">#CAID#</cfoutput>">
<input type="hidden" name="SubmitTime" value="<cfoutput>#CreateODBCDateTime(DateAdd("h",3, Now()))#</cfoutput>">
<INPUT type="Submit" value="Submit" class="smallblue">
<img src="../images/dot_clear.gif" height="2" width="15">                                          
<INPUT type="Reset" value="Clear Form" class="smallblue">
</td>
</tr>
</table>
</CFFORM>

So the form should look like this:

CAID:                     100
Reason:                  Unprofessional Behavior
Level:                     8 Written Warning
Effective Date:         09/17/2004
End/Review Date:    12/17/2004
Notes:                     Violation of Company Policy

But the user should have the ability to change the drop down box for "Reason" and "Level" and be able to change the date or add/edit notes.  User then clicks submit and it updates the dbase by passing to emp_ca-update.cfm?EmpID=1234567.

Does that make sense?



0
 
LVL 14

Accepted Solution

by:
Renante Entera earned 250 total points
ID: 12149270
By the way, just for confirmation.  Is the query name of your code as shown below "caedit" or "qselcaedit" ???

<CFQUERY datasource="myds" name="caedit" blockfactor="100">
     SELECT *
     FROM tbl_correctiveaction, tbl_employees
     WHERE tbl_correctiveaction.EmployeeID=tbl_employees.EmployeeID
     AND tbl_correctiveaction.CAID = #CAID#
</CFQUERY>

And I think I got now your problem.  You could not be able to display the value for Reason and Level of that specific CAID.  Am i right ???

So, here's what you will have to do :

1.  You should have to consider the field that you can relate with your queries "qsel_reasons" and "qsel_level" in order for you to get the correct value/data of Reason and Level to be selected on your select boxes.

2.  Without knowing the field to relate, I am just assuming that both queries have field "CAID".  Much better if you will post the fields involved on the other queries ...

     You may have your select boxes like this :
     ----------------
     For ReasonID
     ----------------
     <select name="reasonid" class="tinyblue">
     <option value=""></option>
     <cfoutput query="qsel_reasons">
     <option value="#ReasonID#" <cfif CAID eq qselcaedit.CAID>selected</cfif>>#type# - #reasonname#</option>
     </cfoutput>
     </select>

     -------------
     For LevelID
     -------------
     <select name="levelid" class="tinyblue">
     <option value=""></option>
     <cfoutput query="qsel_level">
     <option value="#LevelID#" <cfif CAID eq qselcaedit.CAID>selected</cfif>>#levelID# - #levelname#</option>
     </cfoutput>
     </select>

3.  For "Notes" value, you can simply have your code like this :
     <textarea name="notes" cols="40" rows="10" class="tinyblue"><cfoutput>#qselcaedit.notes#</cfoutput></textarea>

Hope this could help you.


Regards,
eNTRANCE2002 :-)
0
 

Author Comment

by:Lee R Liddick Jr
ID: 12176155
The concept helped perfectly...the level and reason queries doesn't have CAID's but the concept you provided worked perfectly...

<select name="reasonid" class="tinyblue">
<option value=""></option>
<cfoutput query="qsel_reasons">
<option value="#ReasonID#" <cfif ReasonID EQ qselcaedit.ReasonID>selected</cfif>>#type# - #reasonname#</option>
</cfoutput>
</select>
0
 
LVL 14

Expert Comment

by:Renante Entera
ID: 12176238
OK.  That's great!

Hope to help you again.


Best regards,
eNTRANCE2002 :-)
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

15 Experts available now in Live!

Get 1:1 Help Now