Solved

An Edit Form with Select DD Boxes

Posted on 2004-09-23
5
159 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

830 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