SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    if ($zee == "Guru") { $zee--;}
    Join Date
    Nov 2005
    Location
    Karachi - Pakistan
    Posts
    1,134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with JaVASCRIPT CODE

    Hi

    below is the code I am using to Show a DIV LAYER when User mouse over any country name. now, when user MOUSE OVER TO SOME COUNTY, a DIV LAYER APPEAR and that shows a ASP page which connects to Database and display some data pertaining to that country.

    Currently I have to make ASP files for each COUNTRY. what i want is to make this efficient by using somefile.asp?country=ENGLAND on line # 37 below. Means when a user MOUSE Over a country, it will send the country name to the javascript, and that will load the asp file.

    Please GUIDE.




    Code JavaScript:
    window.onload = load;
    var paises = new Array();
    var mapas = new Array();
    var banderas = new Array();
    var XML_doc = new Array();
    var XML_listo = new Array();
    var XML_contador = 0;
     
    function load() {
     
       paises.push("afghanistan"); paises.push("bahrain"); paises.push("cyprus");
       paises.push("egypt"); paises.push("iran"); paises.push("iraq");
       paises.push("israel"); paises.push("jordan"); paises.push("kuwait");
       paises.push("lebanon"); paises.push("oman"); paises.push("palestine"); 
       paises.push("qatar"); paises.push("saudia"); paises.push("syria");
       paises.push("turkey"); paises.push("uae"); paises.push("yemen");
     
     
       for (var i=0; i<paises.length; i++) {
          XML_listo[i] = false;
          if (document.implementation && document.implementation.createDocument) {
             XML_doc[i] = document.implementation.createDocument("", "", null);
             XML_doc[i].onload = function () {
                XML_listo[XML_contador] = true;
                XML_contador++;
             };
          }
          else if (window.ActiveXObject) {
             XML_doc[i] = new ActiveXObject("Microsoft.XMLDOM");
             XML_doc[i].onreadystatechange = function () {
                if (XML_doc[XML_contador].readyState == 4) {
                   XML_listo[XML_contador] = true;
                   XML_contador++;
                }
             };
          }
          XML_doc[i].load("paises/" + paises[i] + ".asp"); [B]<-- Here i want .asp?a=England[/B]
          banderas[i] = new Image(27, 19);
          banderas[i].src = "banderas/" + paises[i] + ".jpg";
          mapas[i] = new Image(452, 307);
          mapas[i].src = "mapas/mapa_" + paises[i] + ".gif";
       }
       mapas[i] = new Image();
       mapas[i].src = "mapas/mapa_america_central.gif";
       document.onmousemove = XY;
    }
     
    function XY(e) {
       X = (window.Event)? e.pageX : event.clientX;
       Y = (window.Event)? e.pageY : event.clientY;
       if (X < 225) {
          document.getElementById("informes").style.left = (X + 60) + "px";
       }
       else {
          document.getElementById("informes").style.left = (X - 310) + "px";
       }
       document.getElementById("informes").style.top = (Y - 130) + "px";
       document.getElementById("mideast").style.left = (X + 18) + "px";
       document.getElementById("mideast").style.top = (Y - 130) + "px";
    }
     
    var timer = null;
    function over(ref) {
       window.clearTimeout(timer);
       if (ref == "sudamerica") {
          document.getElementById("imagen").src = "mapas/mapa_mideast.gif";
          document.getElementById("super").src = "mapas/transparente.gif";
          document.getElementById("informes").style.visibility = "hidden";
          document.getElementById("america_central").style.visibility = "hidden";
       }
       else if (ref == "norteamerica") {
          document.getElementById("imagen").src = "mapas/mapa_mideast.gif";
          document.getElementById("super").src = "mapas/transparente.gif";
          document.getElementById("informes").style.visibility = "hidden";
          document.getElementById("america_central").style.visibility = "hidden";
       }
       else if (ref == "america_central") {
          document.getElementById("imagen").src = "mapas/mapa_mideast.gif";
          document.getElementById("super").src = mapas[15].src;
          document.getElementById("informes").style.visibility = "hidden";
          document.getElementById("america_central").style.visibility = "visible";
       }
       else {
          if (ref.id == 3 || ref.id == 7 || ref.id == 9) {//norteamerica
             document.getElementById("imagen").src = "mapas/mapa_mideast.gif";
          }
          else {//sudamerica
             document.getElementById("imagen").src = "mapas/mapa_mideast.gif";
          }
          ref.className = "over";
          document.getElementById("mideast").style.visibility = "hidden";
          document.getElementById("super").src = mapas[ref.id].src;
          document.getElementById("bandera").src = banderas[ref.id].src;
          document.getElementById("pais").innerHTML =
           XML_doc[ref.id].getElementsByTagName("pais")[0].firstChild.nodeValue;
          for (var i=0; i<4; i++) {
             document.getElementById("valor" + i).innerHTML =
              XML_doc[ref.id].getElementsByTagName("valores")[i].firstChild.nodeValue;
          }
          document.getElementById("informes").style.visibility = "visible";
       }
    }
    function out(ref) {
       ref.className = "out";
       timer = window.setTimeout(''+
        'document.getElementById("imagen").src = "mapas/mapa_mideast.gif";'+
        'document.getElementById("super").src = "mapas/transparente.gif";'+
        'document.getElementById("informes").style.visibility = "hidden";'+
        'document.getElementById("mideast").style.visibility = "hidden";',
         333);
    }
    Last edited by zeeshanhashmi; May 20, 2007 at 08:45. Reason: line number editing


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •