Hello guys, I have a list of 7 checkboxes that when the user clicks on any of them, it would run a function to update the content of a table that holds 7 elements. However I have trouble getting it to work. Currently, clicking on the checkboxes seems to have no effect on the table. Am I doing anything wrong here?
[lua]
--Define weekday table local vacSchedule = {1,1,1,1,1,1,1} --Create weekday checkboxes local monSwitch = widget.newSwitch{style = "checkbox",id = "2",initialSwitchState = true} local tueSwitch = widget.newSwitch{style = "checkbox",id = "3",initialSwitchState = true} local wedSwitch = widget.newSwitch{style = "checkbox",id = "4",initialSwitchState = true} local thuSwitch = widget.newSwitch{style = "checkbox",id = "5",initialSwitchState = true} local friSwitch = widget.newSwitch{style = "checkbox",id = "6",initialSwitchState = true} local satSwitch = widget.newSwitch{style = "checkbox",id = "7",initialSwitchState = true} local sunSwitch = widget.newSwitch{style = "checkbox",id = "1",initialSwitchState = true} --Place checkboxes into table weekdaySwitch = {sunSwitch, monSwitch,tueSwitch,wedSwitch,thuSwitch,friSwitch,satSwitch} --When checkboxes are clicked on/off, update the weekday table accordingly local function checkboxSwitchListener( event ) local switch = event.target if switch.isOn == true then vacSchedule[tonumber(switch.id)] = 1 else vacSchedule[tonumber(switch.id)] = 0 end end --Attach listener to check for clicking of the checkboxes for cycleDay = 1, 7 do weekdaySwitch[cycleDay].onPress = checkboxSwitchListener end
[/lua]