Link to home
Start Free TrialLog in
Avatar of Lee R Liddick Jr
Lee R Liddick JrFlag for United States of America

asked on

An Edit Form with Select DD Boxes

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>
Avatar of Renante Entera
Renante Entera
Flag of Philippines image

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 :-)
Avatar of Lee R Liddick Jr

ASKER

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?



ASKER CERTIFIED SOLUTION
Avatar of Renante Entera
Renante Entera
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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>
OK.  That's great!

Hope to help you again.


Best regards,
eNTRANCE2002 :-)