Hi all,
I've been pulling out my hair on this one over the last two days and I'm
stumped.
On a form page I have a series of drop down select boxes, dynamically
produced and named. The "name" of each select (moduleID) is a three-digit
number. So I could have FORM.133, FORM.147, FORM.155 and so on. The
permission ID value is numeric 1 thru 5.
I pull the recordset from a db and create the fieldnames and drop downs,
like so (which works):
<cfloop query="qUsers">
<cfset FORM[moduleID] = qUsers.permissionID>
</cfloop>
It would look like FORM.155 = 3 "(moduleID) = (permissionID)"
<table border="0" cellspacing="0" cellpadding="3">
<cfloop query="qUsers">
<tr>
<td><strong>#moduleName#</strong></td>
<td>
<select name="#moduleID#">
<option value="1" <cfif FORM[moduleID] EQ 1>selected</cfif> >(1) No
Access</option>
<cfif qUsers.moduleID NEQ 133>
<option value="2" <cfif FORM[moduleID] EQ 2>selected</cfif> >(2) View
Only</option>
<option value="3" <cfif FORM[moduleID] EQ 3>selected</cfif> >(3)
View-Edit</option>
<option value="4" <cfif FORM[moduleID] EQ 4>selected</cfif> >(4)
View-Add-Edit</option>
</cfif>
<option value="5" <cfif FORM[moduleID] EQ 5>selected</cfif> >(5)
Complete Access</option>
</select>
</td>
</tr>
</cfloop>
</table>
Next I want to send the form fields to a cfc for db posting. So in my
<cfinvoke> I loop through the FORM vars, like so:
(Notice that I'm forced to prepend an "A" in front of the cfinvokeargument
name - the cfc throws an error if arguments have names beginning with
numbers)
<cfloop query="qUsers">
<cfinvokeargument name="A#moduleID#" value="#FORM[moduleID]#">
</cfloop>
It would look like A155 = 3 "(moduleID) = (permissionID)"
Here's the real problem, trying to update an existing table with this data.
In the CFC, the qPermissionCount gives me a count of how many rows have
unique module numbers (in this case 3).
<cfquery name="qPermissionCount" datasource="#REQUEST.dsnSQL#"
username="#REQUEST.dsnUID#" password="#REQUEST.dsnPWD#">
SELECT U.userID, P.*
FROM #SESSION.companyInfo.companyTablePrefix#_Users_List U,
#SESSION.companyInfo.companyTablePrefix#_Users_List_UserModulesPermissions P
WHERE U.userID = <cfqueryparam cfsqltype="cf_sql_char"
value="#ARGUMENTS.userID#">
AND U.userID = P.userID
</cfquery>
Now, I can't seem to figure out how to loop for 3 records, and match up the
FORM.A155 with the db record of 155 in order to update the permission level
(1 thru 5). It's the SET that's the problem. Notice that the
ARGUMENTS.a101 could be any number from A101 to A160. I can find which
three numbers are being updated from the qPermissionCount recordset.
<cfquery name="updOBJ2" datasource="#REQUEST.dsnSQL#"
username="#REQUEST.dsnUID#" password="#REQUEST.dsnPWD#">
UPDATE
#SESSION.companyInfo.companyTablePrefix#_Users_List_UserModulesPermissions
SET permissionID = <cfqueryparam cfsqltype="cf_sql_integer"
value="#ARGUMENTS.A101#">
WHERE userID = <cfqueryparam cfsqltype="cf_sql_char"
value="#ARGUMENTS.userID#">
AND moduleID = <cfqueryparam cfsqltype="cf_sql_integer"
value="#qPermissionCount.moduleID#">
</cfif>
</cfquery>
Thanks,
Mark
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:235494
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54