![]() |
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"> |
Code:
chosen.push("den");alert("Congradulations! You recieve a complimentary free den!"); // spelling errors Quizmaster: In the Bible, Joseph and Mary rode into Bethlehem on what sort of animal? Contestant: A reindeer. |
not sure that I get it entirely, but I think this is closer...
Code:
<script type="text/javascript"> |
Thanks Phillip! That really cleared up a HUGE error.
So I got it working, except its putting 'den' into the array twice, it should only go in once its checked off, and when it becomes unchecked, should remove 'den' from the array. Any suggestions? Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
You can still use with IE<9 if you add the following to the top of your code:
Code:
if (!Array.prototype.indexOf) { |
Quote:
alert("Are you sure you don't want a Den? They are free!"); chosen.splice(chosen.indexOf("den",1)) Surely you want confirm box where the user can select OK or cancel. |
Quote:
|
Quote:
Quote:
You brought 'this' into the function 'feat' under the variable 'box.' how does box know that its related to that checkbox? But however, I still want to look into the array if 'den' is there. |
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
well, almost. Here's how to make it work in IE8 and below...
Code:
<script type="text/javascript"> |
| All times are GMT +1. The time now is 12:41 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.