Hi Jose,
What you describe is maintaining a many to many join. I take it you want to
edit one parent category, adding and deleting children by inserting and
deleting from the profiles table. I can't tell if your children are
categories or if you have a products table your not telling about. It
doesn't matter because the point is maintaining the join table, which you
have called profiles. I would deal with this as follows...

1. Do one 'outer join' query to generate the form, so for baseball
SELECT A.Code, A.Name, B.ChildCode
FROM Categories A left outer join Profiles B on A.Code = B.ChildCode and
B.ParentCode = [Baseball]
(An outer join using a join predicate will require a full blown RDBMS. Doing
this in Access is left as an exercise...)

This gets you a list of all categories. Categories that are children of
baseball will have a ChildCode in column 3.

2. Generate your form. For each row, if there is a value in ChildCode, call
the checkbox 'deletions', and check it. If not, call the checkbox
'insertions'. Use this code...

<input type=checkbox <@if 'len(<@column ChildCode>)' true='name="deletions"
checked' false='name="selections"'> 
        value=<@column Code>
>&nbsp;<@column Name>

3. Use an onSubmit handler to reverse all 'deletions' checkboxes when the
form is submitted.
function finalise(){
        var field = null;
        for( i=0;i<document.forms[0].elements.length;i++ ){
                field = document.forms[0].elements[i];
                if( field.name == 'deletions' ){
                        if( field.checked ){
                                field.checked = false
                        }else{
                                field.checked = true
                        }
                }
        }
}
4. Back at the server, when the form is submitted, use a standard delete
action. Delete from table Profiles. Drag on the ChildCode column. Use the IN
operator. Put <@arg deletions type=array> in the Value field.

5 Finally, assign the insertions array, <@assign insertions <@arg insertions
type=array>>. Then loop through and do your inserts, ParentCode =
[Baseball], ChildCode = <@var insertions[1,@@rowcounter]>.
        
-----Original Message-----
From: Jose Kuhn [mailto:[EMAIL PROTECTED]]
Sent: 12 August 2002 17:26
To: Multiple recipients of list witango-talk
Subject: Re: Witango-Talk: Passing checkbox "arrays" into a TCF


What I am doing in a nutshell is I have a Category table for various
category types. The table is as follows.

Code, Name, Type

I then have a second table for profiles

ParentCode, ChildCode

I use these two tables for all of my dynamic pop up menus, check
boxes,...etc

For instance I  do a search off the parentcode with baseball and I get and
join code and childcode and I get

Glo,  Gloves
Bat, Bats
Bas, Bases

Now I have a profile manager that helps me link the various category types.
I want to make sure that Bats, and bases only fall under baseball but Gloves
could also fall under hockey.


So the second table could look like

BsBall, Glo
BsBall, Bat
BsBall, Bas
Hockey, Glo

When I go under the Glove category on my web site there is a listing  of all
of the sports types with a check box

Baseball  X
Hockey  X
Basketball  

This allows me to manage which sports the word gloves will appear. The Code
follows



The way I get the FinalArray Data is by merging two arrays. See attached
TCF. 

One with all of the sports.


BsBall, Baseball
Hockey, Hockey
BkBall, Basketball

And one that come from the profile search

BsBall, Baseball
Hockey, Hockey

Is merged into 

BsBall, Baseball, Checked
Hockey, Hockey, Checked
BkBall, Basketball


<@for stop="<@NUMROWS Array=FinalArray Scope=Local>">
  <tr> 
    <td class="Table" width="28%"><@var name=FinalArray[<@currow>,Name]
Scope=Local> </td>
    <td class="Table" width="28%">
      <input type="checkbox" name="Profile_<@var
name=FinalArray[<@currow>,Name] Scope=Local>" value="checked" <@var
name=FinalArray[<@currow>,Checked] Scope=Local>> </td>
    <td class="Table" width="44%">&nbsp; </td>
  </tr>
</@for>

This gives me a list of checkboxes with the ones in the profile checked.

Now when I want to change to profile I want pass, as an array, the checked
values. What I do now create a NUMROWSx3 array and then using the names of
the <@ARG> I do a for loop and get the following array (assuming the user
unchecked hockey and checked basketball

BsBall, Glo
BkBall, Glo

I then Delete off the profile table anything matching glove and insert the
above rows.

My question is doing a for loop "Over the name of of the <@ARG Profile_<@var
name=FinalArray[@@Local$I,Name] Scope=Local>> stupid? Is there a more
elegant way?

Thanks

Jose

on 8/12/2002 11:05 AM, Simon Boddy at [EMAIL PROTECTED] wrote:

> Hi Jose,
> 
> I'm not clear exactly what you want to do. When you say an array of
> checkboxes, checkboxes on forms return name value pairs like any other
form
> input. 
> 
> What makes your checkboxes a group? Are they all named the same? If so,
you
> can get an array of selected values using <@arg name=myCheckboxes
> type=array>. 
> 
> Of course you can use <@arg > tags inside your method, but this tightly
> couples the method to the particular form.
> 
> Does this help? You might need to elaborate.
> 
> Simon.
> 
> -----Original Message-----
> From: Jose Kuhn [mailto:[EMAIL PROTECTED]]
> Sent: 12 August 2002 15:40
> To: Multiple recipients of list witango-talk
> Subject: Witango-Talk: Passing checkbox "arrays" into a TCF
> 
> 
> When I have an array of checkboxes. I want to pass the checked values into
a
> TCF. Right now I create and empty array and fill it with the checked
values
> (using a for loop) and then pass it to the object.
> 
> Is there a more elegant way/?
> 
> 
> Jose
> 
> ________________________________________________________________________
> TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
>               with unsubscribe witango-talk in the message body
> 
> 
> ********************************************************************
> This message is intended only for the use of the person(s) ("the intended
> recipient(s)") to whom it is addressed. It may contain information which
is
> privileged and confidential within the meaning of applicable law. If you
> are not the intended recipient, please contact the sender as soon as
> possible. The views expressed in this communication may not necessarily
> be the views held by LGCSB (Local Government Computer Services Board).
> 
> Any attachments  have been checked by a virus scanner and appear to be
> clean.
> Please ensure that you also scan all messages, as LGCSB does not accept
> any liability for contamination or damage to your systems.
> 
> 
> ********************************************************************
> 
> ________________________________________________________________________
> TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
>               with unsubscribe witango-talk in the message body

-- 
Webologies
150 Robinette Drive
Waynesville, NC 28786
828.627.1994

http://www.webologies.com

----------------------------------------------------------------------------
"You can't make an omelet without breaking eggs"  Boris Badenov
----------------------------------------------------------------------------



********************************************************************
This message is intended only for the use of the person(s) ("the intended
recipient(s)") to whom it is addressed. It may contain information which is
privileged and confidential within the meaning of applicable law. If you 
are not the intended recipient, please contact the sender as soon as
possible. The views expressed in this communication may not necessarily
be the views held by LGCSB (Local Government Computer Services Board).
 
Any attachments  have been checked by a virus scanner and appear to be 
clean.
Please ensure that you also scan all messages, as LGCSB does not accept
any liability for contamination or damage to your systems.


********************************************************************

________________________________________________________________________
TO UNSUBSCRIBE: send a plain text/US ASCII email to [EMAIL PROTECTED]
                with unsubscribe witango-talk in the message body

Reply via email to