/    Sign up×
Community /Pin to ProfileBookmark

List of players(again)

Hi,

My webpage is at [url]www.grafitgroup.ro[/url]

1.The problem, which has been bugging me for weeks, is that I have a map. I put in the cities then I get a score if I am good enough I get in the top 10 (ajax and php are at work here) and the list of top 10 players is displayed.
If the page is refreshed in Firefox the top10 list is updated in IE only when I open a new page is it updated.
There are 4 radiobuttons please pick nr2 because I made a map with the cities already plugged in.

Thank you and I just hope question1 will be history soon.
Me.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@manyamileauthorJan 07.2007 — Sorry everybody,

The right map wasn't at button2.

But now it is, so please go again.

Thanks.
Copy linkTweet thisAlerts:
@manyamileauthorJan 07.2007 — Isn't there anybody out there who can help?Pleeeaase...

I'll explain a little what I did with the Ajax:

  • 1. var ajaxRequest; //I have just one ajax variable declared in the begining.

    .......

    The code goes on and on...

    ......

    The player finishes the game, all 25 cities are found.

    That's when function theend() is called.

    .......

    function theend(){ //the end is called sfarsit in the online code

    stopCount();

    var answer;

    var valo=0;//this is the variable that holds the score.

    valo=Math.floor(250/nrtries *100 )/100; //nrtries - is the number of clicks on map

    myscore=valo

    ajaxtest(valo);

    }


  • function ajaxtest(valo){

    var vallist=0;

    try{

    // Opera 8.0+, Firefox, Safari

    ajaxRequest = new XMLHttpRequest();

    } catch (e){

    // Internet Explorer Browsers

    try{

    ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e) {

    try{

    ajaxRequest = new

    ActiveXObject("Microsoft.XMLHTTP");

    } catch (e){

    // Something went wrong

    alert("Your browser broke!");

    return false;

    }

    }

    }

    ajaxRequest.onreadystatechange = function(){

    if(ajaxRequest.readyState == 4){

    vallist=ajaxRequest.responseText

    mySplitResult="";

    mySplitResult = vallist.split("!!!");

    if (mySplitResult[mySplitResult.length-2]<valo ){

    document.getElementById("winner").style.visibility="visible"; //we have a winner!

    }

    else{deznodamant(valo)}

    }

    }

    if (thismap==0){ //this depends on which of the 4 maps was used

    //there are 4 lists of players.

    //this map is called thisharta in the online code.

    ajaxRequest.open("GET", "lists3.php", true);

    }

    if(thismap==1){

    ajaxRequest.open("GET", "lists5.php", true);

    }

    if(thismap==2){

    ajaxRequest.open("GET", "lists6.php", true);

    }if(thismap==3){

    ajaxRequest.open("GET", "lists7.php", true);

    }

    ajaxRequest.send(null);

    }

    ............

    //After the player has typed in the name and school a function datele() is called.

    ............

    function datele(){

    var i=0;

    var j=0;

    var add=0;

    var nume=document.getElementById("numelemeu").value;//name

    var scoala=document.getElementById("scoalamea").value;//school

    for(i=0; i<mySplitResult.length-6; i++){

    if (i%4==0) { //the begining of each 4 cell row

    if (myscore>mySplitResult[i+3]){ // the present score is better than the score

    //on this row of the table

    if (add==0){

    document.getElementById("C"+j).innerHTML=nume;

    j++

    document.getElementById("C"+j).innerHTML=scoala;

    j++;

    document.getElementById("C"+j).innerHTML=sec;

    j++;

    document.getElementById("C"+j).innerHTML=myscore;

    j++;

    add=1;

    }

    }

    document.getElementById("C"+j).innerHTML=mySplitResult[i];

    j++

    }

    document.getElementById("winner").style.visibility="hidden";

    document.getElementById("premianti").style.visibility="visible";

    var



    url="lists2.php?nume="+escape(nume)+"&scoala="+escape(scoala)+"&myscore="+escape(myscore)+"&



    sec="+escape(sec)+"&thismap="+escape(thismap);

    ajaxRequest.open("GET", url, true);

    ajaxRequest.send(null);

    }



    There! Is that better? Somebody MUST know the answer!
    Copy linkTweet thisAlerts:
    @manyamileauthorJan 08.2007 — More information

    I have a map. I put in the cities, then I get a score and the list of top 10 players is displayed. If I was good enough I will be on the list if not I will still see the list but I won't be on it.

    The new information (if I made it to the list) is sent to php and a text file is updated with this new information.(always)

    Now here comes the problem:

    If I want to play again then I click on a button and the page is refreshed (or I do it from the menu)

    If the page is refreshed in Firefox the top10 list is updated and my name from game1 will still be on list after game2. In IE only when I open a new page is the onscreen list updated - though as I said the text file with the name of the players is always correct.
    Copy linkTweet thisAlerts:
    @_Aerospace_Eng_Jan 08.2007 — Seems like the text file is being cached. Try adding on a random query string to the text file
    [code=php]var jsvar = 'somefile.txt?id=<?php echo rand(); ?>';[/code]
    And you really need to learn to be a little more patient. Other people need help on the forums too not just you. To be honest you never really said WHAT the problem was until now. You didn't really ask a question either you just stated some stuff.
    Copy linkTweet thisAlerts:
    @manyamileauthorJan 08.2007 — Hi Aerospace Eng,

    Ok, I promise I will be patient.

    Thank you for answering.

    I'll keep you posted.
    Copy linkTweet thisAlerts:
    @manyamileauthorJan 08.2007 — I put that line in javascript, i hope that's correct, the code still works but the list is still not updated.

    I am D-O-N-E done.

    I also used header functions for php to prevent caching.

    Aerospace you really helped me a lot. Thank you.
    ×

    Success!

    Help @manyamile spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.18,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...