jchryss Posted May 11, 2008 Posted May 11, 2008 Hi, I am new to all this. I want to have buttons that when pressed would add to a field. For example I would have five buttons:apple,orange,kiwi,strawberry, banana and pear. When I press the apple, banana and pear buttons I want the field (chosenfruit) to show all three items but not the others. Thanks in advance for your help John C
jchryss Posted May 11, 2008 Author Posted May 11, 2008 Addendum when I attach the scripts to buttons now and sequentially they replace the current field data. I want them to append to that data. For example when I sequentially press apple, banana, pear I get pear only. My scripts have two steps: go to field and insert text.
LaRetta Posted May 11, 2008 Posted May 11, 2008 Hi John, I would suggest using Set Field [] instead of insert text. I am unsure whether you are adding the next fruit in a multiline or a comma style list. I will give you both. The script could be the same for every button. The button could have a script parameter attached to it, just specifying the fruit. Then script would be: Set Field [ textField ; textField & ¶ & Get ( ScriptParameter) This would add each fruit in a multi line (list). To have it listed as apple, pear, cherry, change the ¶ to ", " LaRetta
jchryss Posted May 11, 2008 Author Posted May 11, 2008 That worked great except now I have the following: ",apple,pear,banana" How do I get rid of the initial comma
The Shadow Posted May 11, 2008 Posted May 11, 2008 Change it to: Set Field [ textField ; textField & If(not IsEmpty(textField); ", ") & Get ( ScriptParameter) ]
corn Posted May 11, 2008 Posted May 11, 2008 Set Field [ textField; textField & Case ( not IsEmpty ( textField ); ", " ) & Get ( ScriptParameter ) ]
fabriceN Posted May 11, 2008 Posted May 11, 2008 (edited) Set field [ substitute ( list ( field ; Get ( ScriptParameter )) ; ¶ ; "," ) would also work if you don't have multiline entries. But did you consider using a simple value list with checkboxes ? Edited May 11, 2008 by Guest
jchryss Posted May 11, 2008 Author Posted May 11, 2008 Ok all of that worked great and thank you all you gurus. I now agree I would be better served with checkboxes and a value list. When I try that the fruits are on different lines with paragraphs in between rather than on the same line with commas in between (but not at the front lol) I cant find a way to do that.
corn Posted May 11, 2008 Posted May 11, 2008 You can't with checkboxes. Each checked item represents a "value" that is in the field, that value being defined by a new line (carriage return). You could use an auto-enter calculation to substitute the carriage returns with commas but then the checkboxes will untick themselves. You'll need to compromise either with a second field for display or by switching to a method other than the checkboxes.
jchryss Posted May 11, 2008 Author Posted May 11, 2008 I get the same problem when I use radio boxes.
corn Posted May 11, 2008 Posted May 11, 2008 check boxes, radio buttons, drop down lists... they all use "values" from a value list. Values within a field are separated by carriage returns therefore any technique which relies on values won't yield the desired results. You could use two fields, one for entry using the checkbox method, and one for display showing the comma separated values. This second, display field would have a fairly simple calculation: Substitute ( textField; "¶"; ", " )
jchryss Posted May 11, 2008 Author Posted May 11, 2008 the second field uses the set field to apply the calculation?
jchryss Posted May 11, 2008 Author Posted May 11, 2008 I have tried this two ways set field and insert calculated result. fruitfield1 has the data from the checkbox value list with the paragraphs and fruitfield2 attempts to take the info from one and substitute the paragraphs for commas using the substitute command. I have yet to see any commas just my data from fruitfield1 in the same format.
jchryss Posted May 11, 2008 Author Posted May 11, 2008 ok it worked. what was messing me up was that funny looking A. What is that? When I got rid of it, it worked great?
jchryss Posted May 11, 2008 Author Posted May 11, 2008 ok now I dont see the A with the accent on top in this thread. I must be hallucinating.
Recommended Posts
This topic is 6100 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now