Jon is correct... you are using an assignment operator in place of an equality operator. the code you have above executes to mean:
// this isn't a test for the checkbox's state, it just sets it to true if (document.getElementById("ownCheck").checked = true) ownerCheck = true; else ownerCheck = false; i think what you are trying to achieve could be simpler, such as: function GetStoryPoints() { // both ownerCheck and creatorCheck will be true or false, depending // on the state of the checkbox var ownerCheck = document.getElementById ("ownCheck").checked; var creatorCheck = (document.getElementById ("createCheck").checked; if (ownerCheck && creatorCheck) { $.post('/StoryPoint/ListSpecific?retrieveOwned=' + ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $ ("#UserList > option:selected").attr("value"), null, function(data) { $("#storyPointDetail").html(data); }, "html"); } else if (ownerCheck && !creatorCheck) { $.post('/StoryPoint/ListSpecific?retrieveOwned=' + ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $ ("#UserList > option:selected").attr("value"), null, function(data) { $("#storyPointDetail").html(data); }, "html"); } else if (!ownerCheck && creatorCheck) { $.post('/StoryPoint/ListSpecific?retrieveOwned=' + ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $ ("#UserList > option:selected").attr("value"), null, function(data) { $("#storyPointDetail").html(data); }, "html"); } } On Aug 20, 11:39 am, Jon Banner <banali...@googlemail.com> wrote: > double == in your if statements might do the job. > > 2009/8/19 Nick Moy <nick....@gmail.com> > > > > > When the if else statements are removed, they are not perpetually > > checked. > > > On Aug 19, 4:34 pm, labbit <nick....@gmail.com> wrote: > > > Hello, > > > > I'm trying to write an if else statement in javascript so that when a > > > check box is checked, a table will appear, and when it is checked > > > again, another box will appear. However, the checkbox is constantly > > > marked as checked, and I do not know why. I did not set any checked > > > attritube to false or true. What gives? > > > > function GetStoryPoints() { > > > var ownerCheck; > > > var creatorCheck; > > > > if (document.getElementById("ownCheck").checked = true) > > > ownerCheck = true; > > > else > > > ownerCheck = false; > > > > if (document.getElementById("createCheck").checked = true) > > > creatorCheck = true; > > > else > > > creatorCheck = false; > > > > if (ownerCheck && creatorCheck) { > > > $.post('/StoryPoint/ListSpecific?retrieveOwned=' + > > > ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $ > > > ("#UserList > option:selected").attr("value"), null, function(data) { > > > $("#storyPointDetail").html(data); > > > }, "html"); > > > } > > > else if (ownerCheck && !creatorCheck) { > > > $.post('/StoryPoint/ListSpecific?retrieveOwned=' + > > > ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $ > > > ("#UserList > option:selected").attr("value"), null, function(data) { > > > $("#storyPointDetail").html(data); > > > }, "html"); > > > } > > > else if (!ownerCheck && creatorCheck) { > > > $.post('/StoryPoint/ListSpecific?retrieveOwned=' + > > > ownerCheck + '&retrieveCreated=' + creatorCheck + '&creatorID=' + $ > > > ("#UserList > option:selected").attr("value"), null, function(data) { > > > $("#storyPointDetail").html(data); > > > }, "html"); > > > } > > > }