Re: RadioButton Question
- To: mathgroup at smc.vnet.net
- Subject: [mg91089] Re: RadioButton Question
- From: David Reiss <dbreiss at gmail.com>
- Date: Wed, 6 Aug 2008 05:03:05 -0400 (EDT)
- References: <g791ks$9ot$1@smc.vnet.net>
Hi CHris, Take a look at the documentation for Dynamic where one makes use of a second argument. The second argument of dynamic allows you to cause a function to be executed when the state of the dynamic is changed. Your expression would then have the generic form: RadioButtonBar[Dynamic[state,secondArgument&], {"Existing", "New"}] I hope this helps... --David On Aug 5, 4:05 am, Chris Degnen <deg... at cwgsy.net> wrote: > Hi, Can anyone suggest how I can get some radio buttons to run > functions, rather than just set a variable? > > This is a statement to create two buttons that set a value:- > > RadioButtonBar[Dynamic[state], {"Existing", "New"}] > > The following code runs functions, but also shows the buttons in a > list, along with some output. Any suggestions how I can achieve > this functionality but with only the buttons and labels showing, as > above? > > dofunction1[] := x = 1; > > dofunction2[] := x = 2; > > Module[{state = "Existing"}, > {RadioButtonBar[Dynamic[state], {"Existing", "New"}], > Dynamic[If[state == "Existing", dofunction1[], dofunction2[]]]}]