Connecting Tech Pros Worldwide Help | Site Map

CF not returning values to drop down list

Member
 
Join Date: Mar 2007
Posts: 94
#1: Jul 29 '09
Hello,

I've written a script which returns the admin rights of users in a table - their access level, and their priviledges.

The priviledge are returned to a check box and the admin rights to a drop down list. I want this list to have more than one value so that it can be altered.

I've created a loop to run through the drop down options and select the one that matches in the database. However it doesn't appear to be working - its not returning the value in the ViewLevel field. It works on other scripts where I return a single row ID, but not when I return all the rows in the database.

Any ideas what I am doing wrong?

Here's the (stripped down) script:

Expand|Select|Wrap|Line Numbers
  1. <cfquery datasource="repairmdb" name="GetViewLevel">
  2.     select        ViewLevel, ViewText
  3.     from        tblViewLevel
  4.     order by    ViewLevel
  5.     </cfquery>
  6.  
  7.  
  8.     <cfquery name="GetUsers" datasource="repairmdb">
  9.      select distinct    LoginName, 
  10.             FirstName, 
  11.             Surname,
  12.             ViewLevelFK, 
  13.             CreateReports, 
  14.             CreateUncompReport,
  15.             DeleteRecords,
  16.             AdminRights
  17.     from        tblWebsiteUsers
  18.     order by    Surname
  19.  
  20.  
  21.     </cfquery>
  22.  
  23. <div>
  24.             <form action="Devaction_userchange.cfm" method="post">
  25.             <table style="width: 650px;">
  26.  
  27.             <tr>
  28.             <th class="thl" style="width: 150px">User Name</th>
  29.             <th class="thl" style="width: 100px">Access Level</th>
  30.             <th class="thc" style="width: 100px">Create Report</th>
  31.             <th class="thc" style="width: 140px">Create Uncomp. Jobs Report</th>
  32.             <th class="thc" style="width: 100px">Delete Records</th>
  33.             <th class="thc" style="width: 100px">Admin Rights</th>
  34.             </tr>
  35.  
  36.             <cfoutput query="GetUsers">
  37.  
  38.             <tr>
  39.             <td class="thl" style="width: 150px">#FirstName# #Surname#</td>
  40.             <td class="thl" style="width: 100px">
  41.  
  42.             <select name="ViewLevelFK" size="1" class="droplist">
  43.             <cfloop query = "GetViewLevel">
  44.             <option value="#ViewLevel#"<cfif GetUsers.ViewLevelFK EQ ViewLevel> selected</cfif>>#ViewText#
  45.             </cfloop>
  46.             </select>
  47.             </td>
  48.  
  49.  
  50.             <td class="thc" style="width: 100px"><input type="checkbox" name="CreateReports" value="1"<cfif val(CreateReports) NEQ             
  51.  
  52. 0>checked</cfif>></td>
  53.             <td class="thc" style="width: 140px"><input type="checkbox" name="CreateUncompReports" value="1"<cfif val(CreateUncompReport) NEQ     
  54.  
  55.         0>checked</cfif>></td>
  56.             <td class="thc" style="width: 100px"><input type="checkbox" name="DeleteRecs" <cfif val(DeleteRecords) NEQ             
  57.  
  58. 0>checked</cfif>></td>
  59.             <td class="thc" style="width: 100px"><input type="checkbox" name="AdminRights" <cfif val(AdminRights) NEQ             
  60.  
  61. 0>checked</cfif>></td>
  62.  
  63.             <td><input type="submit" value="Update" class="buttons" name="updateUsers" /></td>
  64.             </tr>
  65.  
  66.             </cfoutput>
  67.  
  68.  
  69.  
  70.  
  71.             </form>
  72.  
thanks
Neil
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Sep 4 '09

re: CF not returning values to drop down list


Use a join query instead of two separate queries.
Member
 
Join Date: Mar 2007
Posts: 94
#3: Sep 7 '09

re: CF not returning values to drop down list


Hi acoder,

Thanks - I`ll give it a go!
Reply