same fields two forms, enter data once?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
sx-74
Posts: 22
Joined: Wed Nov 30, 2011 11:27 pm

same fields two forms, enter data once?

Post by sx-74 » Tue Dec 13, 2011 8:21 pm

Hey all,
I am making a contact form as well as an equipment rental form for an IOS app.
Both forms use the same information for some of the fields (name, email, phone) but are on different cards.
Can one field populate the other field, even on different cards?

Ex. "name" on card 1 populates "name" on card 6.

Thanks
- Jay

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: same fields two forms, enter data once?

Post by jacque » Tue Dec 13, 2011 8:29 pm

Sure, use something like this:

Code: Select all

on preOpenCard -- in the second card
  repeat for each item i in "name,address,city,state" -- list fields here, no spaces
     put fld i of cd "firstcard" into fld i
  end repeat
end preOpenCard
That will update the fields just before the second card is opened. Or if you prefer, you can do it on a closefield in the first card so it's dynamically updated on the fly:

Code: Select all

on closeField
  put the short name of the target into tFld
  if tFld is among the items of "name,address,city,state" then
    put target into fld tFld of card "secondcard"
  end if
end closeField
Note the difference between "the target" (which is the field name) and "target" (which is the contents of the field.)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sx-74
Posts: 22
Joined: Wed Nov 30, 2011 11:27 pm

Re: same fields two forms, enter data once?

Post by sx-74 » Wed Dec 14, 2011 7:59 pm

THANK YOU so much!
Very excited to try this.

- Jay

(15 minutes later)
Awesome! This works perfectly!
So excited.

Post Reply