Thread: Resolved Won't append to the array
View Single Post
Old 09-29-2012, 06:05 PM   PM User | #1
akzes
New to the CF scene

 
Join Date: Sep 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
akzes is an unknown quantity at this point
Won't append to the array

Hi Everyone! First time post and enjoying javascript. However, I can't seem to figure out how to append to the array and for the if statement to check if the variable got pushed into the array.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type="text/javascript">
var chosen=[];
var feat=function(chosenfeat){
	if (chosenfeat==="den"){
		if (chosen.indexOf("den")){
			document.getElementById('denid').checked=false;
			alert("Are you sure you don't want a Den? They are free!");
			chosen.splice(chosen.indexOf("den",1))}
		else {
			chosen.push=("den");
			alert("Congradulations! You recieve a complimentary free den!");
			console.log(chosen);}
		
		}
		}
</script>
</head>
<body>
<input type="checkbox" id="denid"  onclick="feat('den');" />Den (NO CHARGE)<br />
</body>
</html>

Last edited by akzes; 09-29-2012 at 09:27 PM..
akzes is offline   Reply With Quote