View Full Version : getelementid in cfloop

08-04-2010, 03:36 PM
I've got a popup page where you can edit a lookup that is used on another form below the popup. On my popup page you can add a new item or delete an item from a list of the records in the lookup. The add and delete is two seperate cfforms, with the delete in a cfloop.

I've got a variable of the currently selected id from the parent form hidden on the popup, so that it remembers the selected item when the parent form is refreshed (to show the new lookup item). It works well on the Add new item, but not on the delete, because in the cfloop it only sets the first record to the variable. Any idea how I can set all the items in the loop to the same variable value, or another way of doing this.

Here is the javascript part to set the hidden variable to the value from the parent form. This is run onload:

function getValues(){
document.getElementById('tempselCategory').value=opener.document.getElementById('tempselCategory').v alue;

And then the deletion part:

<cfloop query="qrySourceList">
<tr valign="middle">
<cfform action="index.cfm?fuseaction=PMP_PC_CPIs.DeleteLuElements</cfoutput>"
onSubmit="tmt_confirm('Delete%20Source?');return document.MM_returnValue">
<td> <input name="imageField" type="image"
alt="Delete Source"
<cfinput type="hidden" name="MM_delete" value="TRUE">
<cfinput type="hidden" name="MM_recordId" value="#qrySourceList.SourceID#">
<cfinput type="hidden" name="PMP_Mod" value="Source">
<cfinput type="hidden" name="tempselCategory" id="tempselCategory">

<td align="left" bgcolor="White"><cfoutput>#qrySourceList.Source#</cfoutput></td>

So when I delete the first record it uses tempselCategory, but for any other records tempselCategory is blank.