Thanks for the help on this problem.
I managed to get it all working flawlessly :)
Thanks all.
Here is the code, the form first, followed by the action page.
They can enter a maximum of 5 equipment items.
Hence I know how many extra and exactly how much to look for in the
action page etc.
-Gel
<-----------This is the Main Edit Form ------------>
<CFQUERY name="EquipmentInfo" datasource="xxxxxx" dbtype="oracle80">
Select Equipment_Type,Equipment_Desc FROM Equipment_TBL
</CFQUERY>
<CFQUERY name="GrabEquipmentInfo" datasource="xxxxx" DBTYPE="Oracle80">
Select * from tblEquipEntry
WHERE tblEquipEntry.MainID = #MainID#
</CFQUERY>
Edit Equipment
<form name="form1" method="post" action="editequipment_action.cfm">
<table width="291" border="0" cellspacing="2" cellpadding="2">
<tr align="center">
<td width="8" class="sigintext" align="left"> </td>
<td width="197" class="sigintext" align="left"
bgcolor="#99CCCC">Choose
Equipment</td>
<td width="66" class="sigintext"
bgcolor="#99CCCC">Hours</td>
</tr>
<CFLOOP Query="GrabEquipmentInfo">
<tr>
<td width="8" class="sigintext" align="left"> </td>
<td width="197" class="sigintext"
align="left" bgcolor="#999999">
<CFOUTPUT> <select
name="chooseequip#GrabEquipmentInfo.EquipID#" class="boxes">
<CFQUERY name="EI" datasource="xxxxx"
dbtype="oracle80">
Select
Equipment_Type,Equipment_Desc FROM Equipment_TBL
WHERE
Equipment_Type = '#GrabEquipmentInfo.equipmenttype#'
</CFQUERY>
<option
value="#GrabEquipmentInfo.equipmenttype#">#EI.Equipment_Desc#</option>
<CFLOOP
query="EquipmentInfo">
<option
value="#equipment_type#">#equipment_desc#</option>
</CFLOOP>
</select>
</td>
<td width="66" align="center" bgcolor="##999999">
<input type="text"
name="hours#GrabEquipmentInfo.EquipID#"
value="#GrabEquipmentInfo.hours#" class="boxes" size="6">
</td>
</tr>
</CFOUTPUT>
</CFLOOP>
<CFIF (5-#GrabEquipmentInfo.recordcount#) GT 0>
<cfloop index="counter" from="1"
to="#Evaluate('5-#grabequipmentinfo.recordcount#')#">
<CFOUTPUT>
<tr>
<td width="8" class="sigintext" align="left"></td>
<td width="197" class="sigintext" align="left"
bgcolor="##999999" >
<select name="chooseequip#counter#"
class="boxes">
<option value="">Please choose equipment
from</option>
<CFLOOP
query="EquipmentInfo">
<option
value="#equipment_type#">#equipment_desc#</option>
</CFLOOP>
</select>
</td>
<td width="66" class="sigintext" align="center"
bgcolor="##999999">
<input type="text"
name="hours#counter#" class="boxes" size="6">
</td>
</tr>
</CFOUTPUT>
</CFLOOP>
</CFIF>
<tr>
<td width="8" align="left"> </td>
<td width="197" align="left"> </td>
<td width="66" align="right">
<CFOUTPUT>
<input type="hidden" name="mainid"
value="#MainID#">
<input type="hidden" name = "extrarecords"
value = "5 - #GrabEquipmentInfo.recordcount#">
</CFOUTPUT>
<input type="submit" value="Submit"
class="buttons">
</td>
</tr>
</table>
</form>
<!----END CONTENT --->
</td>
</tr>
</table>
<-------------------------THIS IS THE ACTION FORM
------------------------>
<CFQUERY name="GrabEquipmentInfo" datasource="xxxxx" DBTYPE="Oracle80">
Select * from tblEquipEntry
WHERE tblEquipEntry.MainID = #MainID#
</CFQUERY>
<CFLOOP query="GrabEquipmentInfo">
<CFIF #Evaluate('hours#GrabEquipmentInfo.EquipID#')# eq 0>
<CFQUERY name="DED" datasource="xxxxx" dbtype="oracle80">
<CFOUTPUT>
DELETE FROM tblEquipEntry
WHERE tblEquipEntry.EquipID =
#Val(GrabEquipmentInfo.EquipID)#
</CFOUTPUT>
</CFQUERY>
<CFELSE>
<CFQUERY name="UpdateEquipmentData" datasource="xxxxxx"
dbtype="oracle80">
UPDATE tblEquipEntry
<CFOUTPUT>
SET EquipmentType =
'#Evaluate('chooseequip#GrabEquipmentInfo.EquipID#')#',
Hours = #Evaluate('hours#GrabEquipmentInfo.EquipID#')#
WHERE tblEquipEntry.EquipID =
#GrabEquipmentInfo.EquipID#
</CFOUTPUT>
</CFQUERY>
</CFIF>
</CFLOOP>
<CFIF extrarecords gt 0>
<cfloop index="counter" from="1"
to="#Evaluate('5-#grabequipmentinfo.recordcount#')#">
<cfif len(evaluate('Form.chooseequip#counter#'))>
<cfquery name="INE" datasource="xxxxx" DBTYPE="Oracle80">
INSERT INTO tblEquipEntry
VALUES
(tblequipentry_seq.nextval,#MainID#,'#Evaluate('Form.chooseequip#counter
#')#',#Evaluate('Form.hours#counter#')#)
</CFQUERY>
</CFIF>
</CFLOOP>
</CFIF>
<!---
<SCRIPT language="Javascript">
parent.close();
</SCRIPT>
--->
<
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists