Hi
I have a site where I have some ajax scripts that are executed by a click on a button like this:
<input type="button" onClick="UpdateArtist('', '<?echo $userid;?>', '', 'showartist', '');">
<input type="button" onClick="UpdateTitle('', '<?echo $userid;?>', '', 'showtitle', '');">
... and so on
And I have 4 of these..
They are lists that is updated by clikcing the artists and titles, so the lists are echoed from a database in the php list files the ajax is opening.
The Ajax scritps there are calling looks like this:
function UpdateArtist(Artist, ID, Task, sideElement, kaldMessage) {
document.getElementById(sideElement).innerHTML = kaldMessage;
try {
req = new XMLHttpRequest(); /* f.eks. Firefox */
} catch(e) {
try {
req = new ActiveXObject("Msxml2.XMLHTTP"); /* IE-versioner */
} catch (e) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP"); /* IE-versioner */
} catch (e) {
req = false;
}
}
}
req.onreadystatechange = function() {svarUpdateArtist(sideElement);};
req.open("GET","ArtistList.php" + "?Artist=" + Artist + "&ID=" + ID + "&Task=" + Task,true);
req.send(null);
}
function svarUpdateArtist(sideElement) {
var output = '';
if(req.readyState == 4) {
if(req.status == 200) {
output = req.responseText;
document.getElementById(sideElement).innerHTML = output;
}
}
}
Only the function name is diffent in the 4 ajax calls..
So... When I run the site, there are no lists shown on the site, but when I click on the buttons the lists are shown, and they are ready to click on...
BUT... the idea is that these lists have to be shown when the page is loaded... I could do a onload in the body tag, but then the userid isn't transfered because the userid hasn't been made at that time in the script, and I can only execute 1 ajax in the onload function for some reason...
So how do I execute all 4 ajax scripts when the page is loaded ??