That title is a mouthful... Hey people! I've been having this bug with a web app project for school that I haven't been able to get passed after trying alternate methods for the past week or so. I'm hoping someone might be able to catch something that I can't...
Okay so here's the code which I believe is the source of the problem:
echo"<div class='RightSidebar'> <button id='AtkBtn' type='button' onclick='attack(".$currentTurn.");'><b>Attack</b></button></a>\n";
Here's the Javascript function:
function attack(turn)
{
if(turn == 1 )
{alert('It is not your turn!!');}
else
{
document.getElementById.("TextLog").innerHTML = "You attack the enemy!";
}
}
(This is the only code in a file named "BattleMethods.js"; the script tags above the opening body tag states we'll be using this file. I can copy that line too if it helps...) No effects are being passed yet (i.e., the effect on the enemy's health). I want to get this running first and then code that out.
Now with that given information I need the following to happen:
1) Player hits the Attack button within a right sidebar div
2) TextLog div below the battle screen div that shows the enemy reveals current relevant information (i.e: "You attack the enemy!")
3) Client-side variables update appropriately (userHP, currentTurn, etc)
That is all. I can get the variables to update with no problem if I can figure out whats not allowing the function to react when player clicks the Attack button. I had done something similar in the item store and it worked fine. So I'm really at a loss. I hope this is enough information! Any help is much appreciated.
HTML where script lies:
echo"<!DOCTYPE html>\n";
echo"<html>\n";
echo"<head>\n";
echo"<title>SlateKeeper -- BATTLEROOM</title>\n";
echo"<meta name='viewport' content='minimum-scale=0.98; maximum-scale=5;initial- scale=0.98;user-scalable=no;width=1024'>\n";
echo"<link rel='stylesheet' type = 'text/css' href='CSS/battleTowersStyles.css'>\n";
echo"<script language= 'Javascript' type = 'text/javascript' src='Javascript/BattleMethods.js'></script>\n";
echo"<style>\n";
echo" body {background-color: #3b4870}\n";
echo"</style>\n";
echo"</head>\n";
<head>
? While it shouldn't matter, placing them as children of<html>
is invalid. – Bergi Apr 19 at 18:31$currentTurn
? Please post the HTML that the PHP produces. – Bergi Apr 19 at 18:32