View Full Version : One of two if statements execute

01-01-2012, 04:18 AM
edit:: got it to work setting inBooth to false in the function where I clear the menu, but then it's refreshing to div so often while you're standing in the booth (30 frames/sec, it's a game) that nothing happens when you click the buttons to buy/sell unless you click really really fast....

anyone know a good way to check whether something is true, then toggle an innerHTML div, then once the value becomes false, toggle the innerHTML div to empty....??simply??

But if I reverse the order the opposite works but then the other doesn't......

if (condition==true ) {
} else {inBooth=false;clearSale();}

if (condition2==true ) {
} else {inBooth=false;clearSale();}

Only the "generateSale()" from the second one executes. If I switch the if blocks, the second one with "generateSale()" executes.

If I change "clearSale();" to a "setTimeout=('clearSale()',1000)" then both execute "generateSale()" but the div it affects flickers repeatedly as it's cleared/remade.

generateSale() changes the innerHTML of a div, clearSale() just overwrites the innerHTML with ' '

var sales2;

function clearSale() {

function generateSale(){
'Buy/Sell: '+' Gold coins: '+playerInventory[lootArray[7]]+'<br>'
+' Consumables:<br>'

+'You have: '+playerItems[itemArray[4]] +' arrows<br>'
+'<input type="button" value="Buy" onclick="buyIt(0);">'+'10 for 50gp<br>'
+'<input type="button" value="Sell" onclick="sellIt(0);">'+'10 for 25gp<br>'

Any ideas? Basically when my character enters the range of an image of a building I have a menu pop up saying you're in a vendor booth.

I want it to run generateSale() which changes a div on the screen to list a bunch of stuff you can buy/sell. When your character is no longer standing in range, I want it to clear that information, so you have to be standing within range in order to trade items.

Currently I can make it generates the sale menu, but it doesn't clear it when you leave the range. I've tried all kinds of "toggle" variables to set whether you're in range or not, but only the second block fires, not the first and I cannot figure out why...

Any ideas? The code all works fine it just won't clear for all the different buildings, only one....

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum