May 11, 200817 yr 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
May 11, 200817 yr Author 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.
May 11, 200817 yr 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
May 11, 200817 yr Author That worked great except now I have the following: ",apple,pear,banana" How do I get rid of the initial comma
May 11, 200817 yr Change it to: Set Field [ textField ; textField & If(not IsEmpty(textField); ", ") & Get ( ScriptParameter) ]
May 11, 200817 yr Set Field [ textField; textField & Case ( not IsEmpty ( textField ); ", " ) & Get ( ScriptParameter ) ]
May 11, 200817 yr 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, 200817 yr by Guest
May 11, 200817 yr Author 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.
May 11, 200817 yr 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.
May 11, 200817 yr 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; "¶"; ", " )
May 11, 200817 yr Author 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.
May 11, 200817 yr Author 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?
May 11, 200817 yr Author ok now I dont see the A with the accent on top in this thread. I must be hallucinating.
Create an account or sign in to comment