<grin> Well, this first idea may not be easier than what you've done so far;
you'll need to be able to use javascript to manipulate the options within a
select control, and you can't do that on Netscape 4.* (I'm not sure about
6.)

 --------

If you can develop this just IE only, I would suggest using two select
controls.  Populate the first with the currently unused steps, and populate
the second (a multi select control) with their existing steps; store the
step identifier as the value, and display the step name (or ID).

Using javascript, give them an add, remove, up and down button to manipulate
the contents of second control. Add moves the item from select1 to select2,
remove does the reverse. Up and down change the order of the options within
the control.

When the user submits the form, use javascript to "select" all the options
in select2; on your action page, you should have a comma-delimited list of
the stepIDs, in the order the group admin wants.  Then delete all the
records for that admin from your "steps order" table, and insert new records
based on the list.

 --------

Alternatively, you could use a text box (name="<stepID>") for each step,
using client-side validation for  distinct integers (or empty) before
submitting.  Then on your action page, you'll have numerous name=value pairs
like 32=1 and 45=2 (assuming 32 and 45 are stepIDs).  Delete the records for
this group admin, and insert new ones based on the values.  (You can deal
with gaps in the numbering either on the client side or on the action page.)


 --------

I wouldn't think you would need to record the number of steps they use in a
separate table; you can get that at any time using a SQL count function.

 --------

Good luck.

-----Original Message-----
From: Diana Nichols [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, March 21, 2001 1:41 PM
To: CF-Talk
Subject: Tracking two lists of numbers


This just can't be as hard as I'm making it!

I have a list of steps (1-20) each of which has 6 fields attached to it,
e.g.:
smstep1.....smstep20
smstep1title.....smstep20title
smstep1desc....smstep20desc
smstep1prob.....smstep20prob
smstep1note.....smstep20note
smstep1date......smstep20date

Title, desc and prob are stored in table(1), as they apply to a group of
users, while the other 3 reside in table(2), which is particular to a
specfic user.

Now, for the issue: Each group admin can define the actual number of steps
they use, and the order in which they appear, and they can change either at
any time.

I have a field in table(1) called smstepslist which is where I store the
list of steps they choose to use, in their order. (e.g. 3,2,4,1,5,7), and
another where called smsteps where I store the total number of steps they
have in their list. (probably not a necessary duplication)

Here's the problem:
I can't figure out the form to allow them to order the steps. I have to keep
track of the original step number, and then place that number in
"smstepslist" in order, based upon their selection in the select box. (And
delete those where the checkbox is unchecked.) In other words, there are two
lists of step numbers that I have to keep up with...the original, and
theirs.

Below is the 21st iteration, and it still doesn't update correctly! I would
be most grateful for any help on the logic here.

<cfif isDefined("update")>
<cfset newstepslist="#form.formsteps#">
<cfloop from=1 to=#form.smsteps# index=this><cfset fieldname="step#this#">
<cfif listfind("#form.fieldnames#",#this#) is 0><cfset
newstepslist=listdeleteat("#newstepslist#",#this#)></cfif>
</cfloop>

<cfquery datasource=#dsn#>
        update companies set smstepslist = '#newstepslist#' where
companyID=#companyID#
</cfquery>

<cflocation url="preferences.cfm" addtoken=no>

<cfelse>
<cfset find="smsteps, smstepslist">
<cfloop from=1 to=20 index="stepno">
<cfset find=listappend("#find#","SMstep#stepno#title, SMstep#stepno#prob")>
</cfloop>
<cfquery name=get datasource=#dsn#>
        select #find# from companies where companyID = #companyID#
</cfquery>
<br>
<span class=head>Edit Steps</span>
<table cellpadding=3>
        <tr><td colspan=3 class=main>Change the order of your steps by
changing the
boxes on the right.<br>
                To eliminate a step, uncheck the box at the left.<br>
                To add steps or edit titles, descriptions or probabilitites,
<a
href="stepedit.cfm">CLICK HERE.</a></td>/tr>

<form name=update action="steporder.cfm?update=1" method=post>
<cfoutput>
<input type=hidden name=smsteps value=#get.smsteps#>
<cfset counter=0>
<cfloop list="#get.smstepslist#" index="companystep"><cfset
counter=#counter#+1>
        <cfset title="get.SMstep#companystep#title"><cfset
prob=evaluate("get.SMstep#companystep#prob")*100>
        <tr><td align=right class=bold bgcolor=cccccc>#evaluate(title)#
(#prob#%)</td>
                <td><input type=checkbox name="#companystep#" checked></td>
                <td><select name="formsteps">
                <cfloop from=1 to=#get.smsteps# index=thisno>
                <option value="#thisno#" <cfif #thisno# is
#counter#>selected</cfif>>#thisno#</cfloop></select></td></tr>
</cfloop></cfoutput>
        <tr><td colspan=3 align=center><input type=submit value="update
steps"></td></tr>
</form>
</table>
</cfif>

TIA!!!

*************
Diana Nichols
Webmistress
http://www.lavenderthreads.com

"One man's magic is another man's engineering." ---Lazarus Long
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to