Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing div tags in another frame

Status
Not open for further replies.

jubalbarca

Programmer
Oct 25, 2008
12
GB
This script;
Code:
function chahe() {
s2 = (slaves*2);
t2 = ((trad/2)*(Math.random()*10));
s5 = (sol*5);
parent.m.location.href="cash.html";
var moneystart = parent.m.document.getElementById("moneystart");
moneystart.firstChild.nodeValue = money;
var slaves = parent.m.document.getElementById("slaves");
slaves.firstChild.nodeValue = s2;
var he = parent.m.document.getElementById("trade");
he.firstChild.nodeValue = t2;
var he = parent.m.document.getElementById("troops");
he.firstChild.nodeValue = s5;
var he = parent.m.document.getElementById("tax");
he.firstChild.nodeValue = pop;
// calculations are here;
money = Math.floor (money + etm + s2 + t2 + pop - s5);
var he = parent.bar.document.getElementById("ho");
he.firstChild.nodeValue = money;
// and back to the report
var he = parent.m.document.getElementById("moneyend");
he.firstChild.nodeValue = money;
}
Is meant to work out the player's money, then put it into these div tags so the player gets a report (I've just put in all the stuff inside the body tags);
Code:
<h2>Financial Report;</h2>
<strong><font size="+1">Treasury;<br></font></strong><div id="moneystart" name="moneystart">0</div>
<br>
<strong>INCOME<br></strong>
Trade;<br><div id="trade" name="trade">0</div>
Taxes;<br><div id="tax" name="tax">0</div>
Slave Labour;<br><div id="slaves" name="slaves">0</div>
<br>
<strong>EXPENDITURE<br></strong>
Troops;<br><div id="troops" name="troops">0</div>
<br>
<strong><font size="+1">Current Treasury;<br></font></strong><div id="moneyend" name="moneyend">0</div>
<br><br>
<a onclick="parent.bar.brand(10);">continue</a>

But I'm getting an 'object required' error...

Anyone have any ideas how to solve this?
 
On which line is the error occurring? It could be anywhere...

Without knowing that, I can point out some things that may or may not be wrong (as there might be other code we don't know about):

- The variables slaves, trad, sol, money, and pop are not defined anywhere (well... money is not defined before its first usage)

- Do you have a frame named 'm'?

- Does your function ever get called? (try putting an alert in. You could also have a series of alerts to find out which line the error is happening on)

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Don't worry, I fixed the problem by moving parts of the script into a different script in the m frame.

Thanks for your help anyway.

P.S. I had defined all my variables and called the script and correctly named my frames though.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top