/    Sign up×
Community /Pin to ProfileBookmark

Ok, so I am very new to all of this.

I started classes for Game Design at then end of August and got thrown right into programing. One of my classes I need to make an html game with javascript.

Here’s what I have:

[CODE]<!DOCTYPE HTML>
<html>
<head>
<script>

var images = document.getElementById(“images”);
var text = document.getElementById(“text”);
var buttonBox = document.getElementById(‘buttonBox’);
var input = document.getElementById(‘input’);

var changeText = function(words) {
text.innerHTML = words.replace(“”, name);
};

var changeImage = function(img) {
images.style.backgroundImage = “url(” + img + “)”;
};

var changeButtons = function(buttonList) {
buttonBox.innerHTML = “”;
for (var i = 0; i < buttonList.length; i++) {
buttonBox.innerHTML += “<button onClick=”+buttonList[i][1]+”>” + buttonList[i][0] + “</button>”;
}
};

var advanceTo = function(s) {
changeImage(s.image)
changeText(s.text)
changeButtons(s.buttons)
};

scenario = {}
var scenario = {
one: {
image: “images/pets.jpg”,
text: “Anyone who has a dog should know some basic medical care. Sometimes rushing an animal to the Vet isn’t the quickest option. We will go through two scenarios that will help should either ever happen with your dog.”,
buttons: [[“Scenario One”,”advanceTo(scenario.two)”], [“Scenario Two”,”advanceTo(scenario.seven)”], [“List of Bad Food”, “advanceTo(scenario.twelve)”]]

},
two: {
image: “images/sunnyTrail.jpg”,
text: “It’s a gorgeous 80 degree day in July. The sky is blue and there isn’t a cloud in the sky. You look at your dog laying on the couch with his tongue lolling out the side of his mouth. You ask him if he wants to go for a hike and he perks his ears up and jumps off the couch wiggling his whole body in excitement! You pack a few water bottles into a pull-string bag, get your dog leashed up and make your way outside. You’re about an hour into your hike when you notice your dog isn’t leading anymore which he usually does. You look back and see him laying on his side panting heavily. You rush over to him and….”,
buttons: [[“Get him in the shade”, “advanceTo(scenario.three)”],[“Get him up and cont”, “advanceTo(scenario.four)”]]
},
three: {
image: “images/shade.jpg”,
text: “You see a shaded area under a bunch of trees not far away. You pick him up and place him into the shade to get him out of the sun!”,
buttons: [[“Get him to drink water”, “advanceTo(scenario.five)”], [“Pour water on him”, “advanceTo(scenario.six)”]]
},
four: {
image: “images/wrong.jpg”,
text: “You pull him up and continue on your hike thinking he’s just tired. You tell him you’ll take a break in a couple minutes to find a nice place to relax. Next thing you know, he collapses again and stops responding….”,
buttons: [[“Go Back”, “advanceTo(scenario.two)”]]
},
five: {
image: “images/wrong.jpg”,
text: “You try to get him to drink water but he doesn’t have the energy to do it….”,
buttons: [[“Go Back”, “advanceTo(scenario.three)”]]
},
six: {
image: “images/pourWater.jpg”,
text: “You grab a water bottle out of your bag and start pouring it on his head, neck, and belly. He starts to pick his head up licking the water dripping from his head. You then pour some water out a bottle and he starts drinking it as it falls! (NOTE: If there is a body of water nearby, a quick dip can also be an option. Just like we, humans go swimming to cool off, it helps dogs as well. Also, if you have a cloth or towel, wetting the cloth/towel and rubbing it on the areas mentioned above also works. It is also important to keep your dog hydrating on hot days especially when being active.) Great job! You possibly saved your best friends life! Just to be on the safe side you might want to swing him by his Veterinarian just to make sure there is no lasting damage!”,
buttons: [[“Good Job! Go Back”, “advanceTo(scenario.one)”]]
},
seven: {
image: “images/cooking.jpg”,
text: “It’s dinner time so you go into the kitchen to make some food. Like always, your dog follows you and watches you at work. You decide to grab a bag of grapes to munch on. You turn back to your prepping when you hear a thud and look to find the bag of grapes on the ground and your fido munching on the bag of grapes as well. You rush over and grab the bag out of his mouth to find the bag empty! You know grapes are very toxic to dogs so you….”,
buttons: [[“Rush to Hospital”, “advanceTo(scenario.eight)”], [“Make him vomit”, “advanceTo(scenario.nine)”]]
},
eight: {
image: “images/sickVet.jpg”,
text: “Your usual Veterinary hospital is closed because it’s 8 o’clock pm on a Saturday so you rush to the nearest 24 Hour hospital which is almost an hour away. You get there and they induce vomiting and tell you he needs to be on IV fluids for 36-72 hours. They tell you good job for bringing him in but that you could have used a common household product, Hydrogen Peroxide, to make him vomit at home which would have been much quicker than rushing him in because that allowed some time for absorption.”,
buttons: [[“Go Back”, “advanceTo(scenario.seven)”]]
},
nine: {
image: “images/hydrogenPeroxide.png”,
text: “You run to your medicine cabinet and grab the bottle of hydrogen peroxide. Your dog is about 50 pounds so you pour about 2 tablespoons of the peroxide down his throat to make him vomit the grapes up. You wait a little bit and he starts to retch and then he expels the grapes! Good job, next you should….(NOTE: Rule of thumb for peroxide is for every pound of the dog, he/she gets 0.5ml to 1ml of peroxide. 15mls =1 tbsp and 5mls = 1tsp)”,
buttons: [[“Get him to Drink”, “advanceTo(scenario.ten)”], [“Relax”, “advanceTo(scenario.eleven)”]]
},
ten: {
image: “images/drink.jpg”,
text: “You know how much he loves to drink from the hose, so you bring him outside and turn on the hose because you know he’ll drink it. You want him to hydrate after vomiting so he doesn’t get dehydrated. Now you can relax, you took immediate action so there’s a very low chance there was any absorption! You should follow up with your veterinarian the next day incase he/she wants you to bring your dog in for IV fluids to minimize the risk of kidney damage.”,
buttons: [[“Good Job! Go Back”, “advanceTo(scenario.one)”]]
},
eleven: {
image: “images/relax.jpg”,
text: “You got him to eliminate the toxic grapes so it’s a job well done. (NOTE: Job well done yes, but you need to make sure he drinks water to stay hydrated since vomiting can cause dehydration.) “,
buttons: [[“Go Back”, “advanceTo(scenario.nine)”]]
},
twelve: {
image: “images/badFood.jpg”
text: “Here is a short list of foods your dog shouldn’t eat”,
buttons: [[“Avocado”,”advanceTo(scenario.thirteen)”], [“Bones”,”advanceTo(scenario.fourteen)”], [“Chocolate”,”advanceTo(scenario.fifteen)”], [“Garlic”,”advanceTo(scenario.sixteen)”], [“Grapes/Raisins”,”advanceTo(scenario.seventeen)”], [“Macadamia Nuts”, “advanceTo(scenario.eighteen)”], [“Onion”, “advanceTo(scenario.ninteen)”], [“Xylitol”,”advanceTo(scenario.twenty)”]]
},
thirteen: {
image: “images/avocado.jpg”
text: “Avocado’s consist of <i>Persin</i> which is a toxin to domestic animals.”,
buttons: [[“Go Back”,”advanceTo(scenario.twelve)”]]
},
fourteen: {
image: “images/bones.jpg”
text: “Raw hide bones can be dangerous but if you are monitoring them making sure they aren’t taking big chunks out those are ok. It’s turkey bones, chicken bones ,etc that are a no no for dogs. They splinter easily and can cut the Digestive System.”,
buttons: [[“Go Back”,”advanceTo(scenario.twelve)”]]
},
fifteen: {
image: “images/chocolate.jpg”
text: “Chocolate is well known for being bad for dogs. It’s due to <i>Theobromine</i> being toxic to dogs. Dark chocolate and unsweetened baking chocolate are the most dangerous. Chocoate can cause vomiting, diarhea, and heart problems.”,
buttons: [[“Go Back”,”advanceTo(scenario.twelve)”]]
},
sixteen: {
image: “images/garlic.jpg”
text: “Garlic kills their red blood cells causing anemia.”,
buttons: [[“Go Back”,”advanceTo(scenario.twelve)”]]
},
seventeen: {
image: “images/grapesAndRaisins.jpg”
text: “The star of Scenario Two, Grapes(and Raisins). These can cause kidney failure in dogs”,
buttons: [[“Go Back”,”advanceTo(scenario.twelve)”]]
},
eighteen: {
image: “images/macadamiaNutes.jpg”
text: “Just six macadamia nuts can make a dog very sick. So watch out for these nuts and dogs since so few can make them very sick.”,
buttons: [[“Go Back”,”advanceTo(scenario.twelve)”]]
},
nineteen: {
image: “images/onion.jpg”
text: “Onions kill their red blood cells causing anemia”,
buttons: [[“Go Back”,”advanceTo(scenario.twelve)”]]
},
twenty: {
image: “images/xylitol.jpg”
text: “Xylitol is a sweetener found in many foods. This sweetener causes dogs blood sugar to drop and can cause liver failure. NOT SO FUN FACT: Peanut butter will be adding xylitol at some point which is surprising since so many dogs love peanut butter, but there are companies that make peanut butter specifically for dogs so if the day comes then you can simply go and purchase the dog specific peanut butter!”,
buttons: [[“Go Back”,”advanceTo(scenario.twelve)”]]
},

};

advanceTo(scenario.one)

</script>

</body>
</html>[/CODE]

If you delete scenario’s twelve to twenty it works fine, but when twelve to twenty is on it brings a blank page. I have been reading through it for almost 2 hours now and I can’t figure this out.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@Kaguar77authorOct 19.2016 — Any help would be very much appreciated
Copy linkTweet thisAlerts:
@KeverOct 19.2016 — You're missing commas after some image properties.
Copy linkTweet thisAlerts:
@Kaguar77authorOct 19.2016 — That didn't work ?
Copy linkTweet thisAlerts:
@KeverOct 19.2016 — What error are you getting in the console?
Copy linkTweet thisAlerts:
@Kaguar77authorOct 19.2016 — Well apparently I'm a little slow in the morning. It did work! Thank you! I don't even know how that happened because I strictly copied and pasted from the ones that worked.
×

Success!

Help @Kaguar77 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...