# Functions and Event handlers

**URL:** <https://forum.code.org/t/functions-and-event-handlers/15418>\
**Category:** Unit and Lesson Discussion\
**Tags:** csp-unit-5, csp-unit-5-lesson-18\
**Created:** [April 6, 2018, 2:49am UTC](https://forum.code.org/t/functions-and-event-handlers/15418 "2018-04-06T02:49:36Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![mhwatts](https://avatars.discourse-cdn.com/v4/letter/m/8797f3/32.png) [@mhwatts](https://forum.code.org/u/mhwatts)\
**Post date:** [April 12, 2018, 4:50pm UTC](https://forum.code.org/t/functions-and-event-handlers/15418/4 "2018-04-12T16:50:30Z")

</div>

I agree with the prior comments. I do have an example of a time when I have wanted to define event handlers in functions, and in fact, in loops. The code sample below creates 20 buttons that scroll. Only 11 are visible at any time. I’ve used a similar approach to making a spreadsheet like display in appLab. This is clearly beyond the minimum scope of CSP, but I have students who ask, so it is nice to be able to show them how it can be done.

[https://studio.code.org/projects/applab/WVw\_r8mdpwB2dRK6hEs9Ng](https://studio.code.org/projects/applab/WVw_r8mdpwB2dRK6hEs9Ng)

// make a bunch of buttons that do similar things

 ![](https://us1.discourse-cdn.com/flex016/uploads/codeorgforum/original/2X/8/8daa5d7322665b5d73a9ebf1ed7f9bbb8726010a.png)

---

_[View the full topic](https://forum.code.org/t/functions-and-event-handlers/15418)._
