Maybe I should explain it differently.

When I query my database...

action.cfm
========

<cfquery name="ListElement" datasource="profiles" dbtype="ODBC">
        SELECT      *
        FROM        profiles
        WHERE       strUsername = '#auth#'
</cfquery>

I then display, with check boxes the results from field "strSelect"

<cfset strSelectList = ''>
<cfoutput query="ListElement"> 
        <cfset strSelectList = ListAppend(strSelectList,ListElement.strSelect)>
</cfoutput>

<form action="add-action.cfm" method="post">
<cfloop list="#strSelectList#" index="i">
<input type="checkbox" name="select" value="#i#">
</cfloop>
<input type="submit" value="Update" class="navlinks">
</form>

An example output from the above code would be...

[  ] dir1
[  ] dir2
[  ] dir3
[  ] dir4
[  ] dir5

So if the user clicks on "dir2" and "dir5" I pass the results to another template 
"add-action.cfm" which adds the selection to my database into field "strOmit".
If they go back to the preferences page and select additional directories and then 
click on the UPDATE the items get appended and re-inserted into "strOmit" field.

What I want to happen is this. When the user clicks on the check boxes I want those 
selections DELETED from the "strSelect" field in my database but inserted into the 
field 
strOmit. The insertion part is working. I can't figure out how to delete the user 
selections from the strSelect field?

add-action.cfm
============

<cfquery name="GetEnv" datasource="user-profiles" dbtype="ODBC">
        SELECT      *
        FROM        profiles
        WHERE       strUsername = '#auth#'
</cfquery>

<cfset SelectStrOmit = ValueList(GetEnv.strOmit)>
<cfset AppendStrOmit = ListAppend(SelectStrOmit,FORM.select)>

<!--- Update field strOmit with results from AppendStrOmit --->
<cfquery name="UpdEnv" datasource="user-profiles" dbtype="ODBC">
        UPDATE      profiles
        SET
        strUsername = '#auth#',
        strOmit=<cfqueryparam value="#AppendStrOmit#" cfsqltype="CF_SQL_LONGVARCHAR">
        WHERE           strUsername = '#auth#'
</cfquery>


On Thu, 14 Nov 2002 11:11:55 -0500, John Morgan wrote:

> Assuming that your query is returning a boolean field that indicates the 
> include state, you could order on this field and use the GROUP option of 
> the CFOUTPUT tag and some conditional logic to control formatting the output.
> 
> Pseudo-example Code:
> 
>   <cfoutput query="myquery">
>          <cfif myquery.showthis>
>                  Preferences: (Click to omit directories from listing)
>          <cfelse>
>                  Preferences: (Click to add directories to listing)
>          </cfif>
>          <cfoutput group="showthis">
>          <!--- your form input code here --->
>          </cfoutput>
> </cfoutput>
> 
> 
> At 09:48 AM 11/14/2002 -0500, you wrote:
> >Hi,
> >
> >I have a preferences page that lists directories with check boxes. This is 
> >displaying by querying my database. It looks something like this:
> >
> >Preferences: (Click to omit directories from listing)
> >
> >[  ] dir1
> >[  ] dir2
> >[  ] dir3
> >[  ] dir4
> >[  ] dir5
> >
> >[ UPDATE ]
> >
> >Preferences: (Click to add directories to listing)
> >
> >No directories selected.
> >
> >[ UPDATE ]
> >
> >
> >So if the user checked on boxes dir2 and dir4 and clicks on the "update" I 
> >then want the screen to appear like:
> >
> >[  ] dir1
> >[  ] dir3
> >[  ] dir5
> >
> >[ UPDATE ]
> >
> >Preferences: (Click to add directories to listing)
> >
> >[  ] dir2
> >[  ] dir4
> >
> >[ UPDATE ]
> >
> >I'm not how to make this happen using my queries?
> >
> >
> >---------------------------------------------------
> >Colonel Nathan R. Jessop
> >Commanding Officer
> >Marine Ground Forces
> >Guatanamo Bay, Cuba
> >---------------------------------------------------
> >
> >
> >
> >
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

Reply via email to