Display what fields a user missed in an answer box?

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

CuriousOne
Posts: 14
Joined: Sun Dec 30, 2018 11:16 pm

Display what fields a user missed in an answer box?

Post by CuriousOne » Wed Jan 09, 2019 5:04 pm

Hi,
What is the best way to display what fields a user missed when they press the submit button.

I have 4 fields that I would like a user to fill it.
If they hit the submit button and have not filled in all the fields an answer box pops up saying please fill in the empty fields above.


Thank you

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Display what fields a user missed in an answer box?

Post by richmond62 » Wed Jan 09, 2019 5:36 pm

Filler.png
Attachments
Field Filler.livecode.zip
Here's the stack
(1.25 KiB) Downloaded 194 times

CuriousOne
Posts: 14
Joined: Sun Dec 30, 2018 11:16 pm

Re: Display what fields a user missed in an answer box?

Post by CuriousOne » Wed Jan 09, 2019 5:46 pm

Hi Richmond,
Thank you for pointing me in the right direction.

Based on what you built I came up with the following.
Answer PopUp Test.zip
(1.41 KiB) Downloaded 236 times

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Display what fields a user missed in an answer box?

Post by richmond62 » Wed Jan 09, 2019 6:57 pm

zzz.png
-
I'm afraid that yours is a bit problematic insofar as it only notifies us
that ONE field has not been filled.

CuriousOne
Posts: 14
Joined: Sun Dec 30, 2018 11:16 pm

Re: Display what fields a user missed in an answer box?

Post by CuriousOne » Wed Jan 09, 2019 7:23 pm

For what I am doing that would be ok.
But is it possible to loop through and add the missing fields to an array then display the array values in the answer dialogue box?

Thank you

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9359
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Display what fields a user missed in an answer box?

Post by richmond62 » Wed Jan 09, 2019 8:32 pm

is it possible
Probably, but I don't know as I am only a simple fellow. 8)

SparkOut
Posts: 2852
Joined: Sun Sep 23, 2007 4:58 pm

Re: Display what fields a user missed in an answer box?

Post by SparkOut » Wed Jan 09, 2019 8:46 pm

Yes, you can do whatever you like, but there's no need for an array.
Loop through, yes.
Build a list of fields requiring completion, yes. (List being one variable, each iteration of the loop appending a missing field if appropriate.)
Answer the variable, giving the whole list.
Richmond already demonstrated that. Simple describes his code rather than his intellect.

CuriousOne
Posts: 14
Joined: Sun Dec 30, 2018 11:16 pm

Re: Display what fields a user missed in an answer box?

Post by CuriousOne » Wed Jan 09, 2019 9:55 pm

Hi everyone,
Thanks for all of your help.
Here is what I ended up with.
Answer Popup Test 3.png
Answer PopUp Test 3.livecode.zip
(1.51 KiB) Downloaded 218 times
Thank you

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Display what fields a user missed in an answer box?

Post by dunbarx » Wed Jan 09, 2019 9:56 pm

So much fun.

Put this into your "Submit" button script:

Code: Select all

on mouseUp
   repeat with z = 1 to 4
      if fld z = "" then put z & return after accum
      if accum <> "" then answer "The following fields require data:" & return & return & accum
   end repeat
end mouseUp
You can always embellish this by giving the names of the empty fields instead of merely their number.

Craig Newman

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Display what fields a user missed in an answer box?

Post by Klaus » Thu Jan 10, 2019 12:40 pm

Or rather:

Code: Select all

on mouseUp
   repeat with z = 1 to 4
      if fld z = "" then put z & return after accum
   end repeat
   if accum <> "" then answer "The following fields require data:" & return & return & accum
end mouseUp

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Display what fields a user missed in an answer box?

Post by dunbarx » Thu Jan 10, 2019 3:14 pm

Klaus,

Are there invisible chars that set your script apart from mine? 8)

Craig

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Display what fields a user missed in an answer box?

Post by Klaus » Thu Jan 10, 2019 3:15 pm

I thought it would be a good idea to show the dialog after all fields have been inspected.
Not? :D

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Display what fields a user missed in an answer box?

Post by bogs » Thu Jan 10, 2019 3:34 pm

Not not :)
Image

CuriousOne
Posts: 14
Joined: Sun Dec 30, 2018 11:16 pm

Re: Display what fields a user missed in an answer box?

Post by CuriousOne » Thu Jan 10, 2019 4:44 pm

Wow, Thanks I am learning quite a bit!
Using accum makes things much cleaner than what I came up with.

Thank you

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Display what fields a user missed in an answer box?

Post by dunbarx » Thu Jan 10, 2019 7:44 pm

Klaus.

You know, I used the test stack provided, which had only one field empty. So I both our handlers worked identically. You might say I did not test exhaustively.

Broadly, on the handlers' own merits, I must have missed HC 101. :oops:

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”