# A little help with some toggle code

**URL:** https://forum.kirupa.com/t/a-little-help-with-some-toggle-code/326231
**Category:** web dev
**Created:** [November 30, 2011, 6:37pm UTC](https://forum.kirupa.com/t/a-little-help-with-some-toggle-code/326231 "2011-11-30T18:37:58Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![m2244](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@m2244](https://forum.kirupa.com/u/m2244)
#### Post date: [November 30, 2011, 6:37pm UTC](https://forum.kirupa.com/t/a-little-help-with-some-toggle-code/326231/1 "2011-11-30T18:37:58Z")

</div>

Hello,

I am simply trying to get this stupid thing to toggle on and off. Can anyone tell me why this code is not working? It is only running the code in the IF, not the ELSE.

```auto

function showHidePup(pupUrl, pupTitle)
{
	if($('#boxPup').toggle(false))
	{
		alert("I'm in the IF");
		$('#boxPup').toggle(true);
		var flashvars = {};
		var params = {};
		params.quality = "low";
		var attributes = {};
		swfobject.embedSWF("pop_up.swf", "popUpDiv", "700", "520", "9.0.0", false, flashvars);//, params, attributes
	}
	else if($('#boxPup').toggle(true))
	{
		alert("I'm in the ELSE");
		$('#boxPup').toggle(false);
	}

```
