Page 1 of 2

Display what fields a user missed in an answer box?

Posted: Wed Jan 09, 2019 5:04 pm
by CuriousOne
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

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

Posted: Wed Jan 09, 2019 5:36 pm
by richmond62
Filler.png

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

Posted: Wed Jan 09, 2019 5:46 pm
by CuriousOne
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 337 times

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

Posted: Wed Jan 09, 2019 6:57 pm
by richmond62
zzz.png
-
I'm afraid that yours is a bit problematic insofar as it only notifies us
that ONE field has not been filled.

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

Posted: Wed Jan 09, 2019 7:23 pm
by CuriousOne
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

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

Posted: Wed Jan 09, 2019 8:32 pm
by richmond62
is it possible
Probably, but I don't know as I am only a simple fellow. 8)

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

Posted: Wed Jan 09, 2019 8:46 pm
by SparkOut
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.

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

Posted: Wed Jan 09, 2019 9:55 pm
by CuriousOne
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 325 times
Thank you

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

Posted: Wed Jan 09, 2019 9:56 pm
by dunbarx
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

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

Posted: Thu Jan 10, 2019 12:40 pm
by Klaus
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

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

Posted: Thu Jan 10, 2019 3:14 pm
by dunbarx
Klaus,

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

Craig

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

Posted: Thu Jan 10, 2019 3:15 pm
by Klaus
I thought it would be a good idea to show the dialog after all fields have been inspected.
Not? :D

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

Posted: Thu Jan 10, 2019 3:34 pm
by bogs
Not not :)

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

Posted: Thu Jan 10, 2019 4:44 pm
by CuriousOne
Wow, Thanks I am learning quite a bit!
Using accum makes things much cleaner than what I came up with.

Thank you

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

Posted: Thu Jan 10, 2019 7:44 pm
by dunbarx
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