Okay, problem number two.
I've got a bit of code:
That fetches some html that's just been printed by an ASP page, and prints it to a div.
There's some code afterwards:
That checks a hidden HTML field for a 1 or a 0. If it's a 1, it hides a div. If it's a 0, it shows a div. By default in the html, the field is set to 0.
Trouble is, the if statement is delayed. If I want to hide that div, I have to wait for the condition to get a 1 twice. Vice-versa for the 0.
However, if I put an alert saying "hello world!" between the two code snippets I gave you, it works!
It's almost as though the HTML is being written too late for the javascript to validate the if statement.
Trouble is, if I put a sleep function I found between those bits of code, it doesn't work.
What the hell is the problem here?
Any help's appreciated because I'm stuck!
Cheers,
Karl.
I've got a bit of code:
Code:
xmlHttp.onreadystatechange=caravanSearchStateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
That fetches some html that's just been printed by an ASP page, and prints it to a div.
There's some code afterwards:
Code:
if (document.getElementById('hideHeaders').value == '1') {
document.getElementById('resultsHeader').className = ' none';
}
else {
document.getElementById('resultsHeader').className = 'floatleft paddingtop15';
}
That checks a hidden HTML field for a 1 or a 0. If it's a 1, it hides a div. If it's a 0, it shows a div. By default in the html, the field is set to 0.
Trouble is, the if statement is delayed. If I want to hide that div, I have to wait for the condition to get a 1 twice. Vice-versa for the 0.
However, if I put an alert saying "hello world!" between the two code snippets I gave you, it works!
It's almost as though the HTML is being written too late for the javascript to validate the if statement.
Trouble is, if I put a sleep function I found between those bits of code, it doesn't work.
What the hell is the problem here?
Any help's appreciated because I'm stuck!
Cheers,
Karl.