Gene, Thanks!

Unfortunately not that simple.  It doesn't pass a null value.  If I have 
three of them and only two addresses I get a list with only two elements in 
it, not two and a null.  My *current* idea is to put the default
<input type="text" value="--None--" etc...
for any field that does not have a value.  Then use basically your script 
to parse it out.  This will break though if someone enters something  and 
then decides it was a mistake, deletes it, and types it on the next 
line.  I thought maybe I could count the list elements to make sure they 
were correct but then what....?

Does CFinput work the same way I wonder?

At 11:39 PM 6/21/2001 -0700, you wrote:
>Aimee,
>
>Here's one possible way:
>
>The form fields for the addresses, all named "address", will produce
>a comma-delimited list with as many elements as people. That is,
>even if some of the address fields are blank, the form will still pass
>those to the action template.
>
>I assume you're also using a unique ID number for each contact,
>so you could populate the initial form with hidden input fields, like
>this, to pass the ID numbers retrieved via your second query:
>
><INPUT TYPE="hidden" NAME="ContactID"
>VALUE="#ContactID#">
>
>Then you should be able to loop through the ContactIDs using LIST
>functions, something like this to save the info:
>
><CFSET Counter=0>
><CFLOOP INDEX="ThisContactID"  LIST="#Form.ContactID#">
>         <CFSET Counter=Counter+1>
>         <CFQUERY NAME="SaveContact" DATASOURCE="yourdb">
>                 UPDATE Contacts
>                 SET Name="#ListGetAt(Form.Name, Counter)#",
>                 Address="#ListGetAt(Form.Address, Counter)#"
>                 WHERE ContactID=#ThisContactID#
>         </CFQUERY>
></CFLOOP>
>
>ListGetAt combined with the Counter number will keep the
>information in sync...
>
>Gene Kraybill
>LPW & Associates
>Mansfield, PA
>
>On 21 Jun 2001, at 20:27, Aimee Abbott wrote:
>
> >
> > Hello everyone!
> >
> > I have a database of companys, names, contacts and addresses.  Not all
> > companys have contact addresses.  I am setting up a form that will allow
> > people to come and change their address.  They will get to the form by
> > entering a url with a primary key at the end of it.  This will query up 
> the
> > company and then a second query will get the people.  The second gets the
> > contact names and addresses -- there can be as many as a dozen
> > contacts.  That is the one I am having trouble with.  What I have done is
> > set it up so (in simple form)
> >
> > <form action...whatever>
> > <cfoutput query="first">
> > <!--- company info up here.  Only one company per web page. --->
> > </cfoutput>
> >
> > <cfoutput query="second">
> > name: <input type=text name=person value=#name#>
> > address: <input type=text name=address value=#address#>
> > </cfoutput>
> >
> > </form>
> > Now, like I said there can be a lot of contact names.
> >
> > So, then on the next page where I save it in the database, what do I 
> do?  I
> > get the information in the form of a list. Where
> > #name#=bob, mary, alice, harry, john
> > but not everyone has an address so I might get
> > #address#=chicago, minneapolis, rome
> >
> > I need to some how match these up somehow and update the record.  Any idea
> > how I can go about doing this?
> >
> > I have thought about the first page having some sort of number appended on
> > to the end of the variable name so the form would somehow have name1,
> > name2, name3, name4 but I don't actually know how to do that.
> >
> > Or from the second page, can I access individual list elements?  And even
> > if I could, how could I know that bob is from chicago, mary is blank and
> > alice is from minneapolis?
> >
> > If I haven't explained this well enough please let me know!
> >
> > Thanks much!
> >
> >
> >
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to