# Quick explanation: my logic is failing me

**URL:** https://forum.kirupa.com/t/quick-explanation-my-logic-is-failing-me/311858
**Category:** web dev
**Created:** [July 19, 2010, 12:37am UTC](https://forum.kirupa.com/t/quick-explanation-my-logic-is-failing-me/311858 "2010-07-19T00:37:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![spyderfx](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@spyderfx](https://forum.kirupa.com/u/spyderfx)
#### Post date: [July 19, 2010, 12:37am UTC](https://forum.kirupa.com/t/quick-explanation-my-logic-is-failing-me/311858/1 "2010-07-19T00:37:50Z")

</div>

This code keeps returning multiple values according to where the value is on the list. IE: The 5th checkbox returns one value, the 4th returns the same one twice. Can anyone explain to me why this is happening?

```auto

function filterCal() {
        var filterValues = "";
        for (var i=0; i < document.categories.music.length; i++) {
            if (document.categories.music*.checked) {
                filterValues = filterValues + document.categories.music*.value + "
";
            }
            document.write(filterValues);
        }
    }

```
