Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Piccolo problema col mio script.. (risolto)

    Salve a tutti, è la prima volta che scrivo sul forum, mi servirebbe un piccolo aiuto con questo script..
    In poche parole c'è la prima funzione "controlla" che fa il suo lavoro egregiamente.. quando però handleResponse deve fare il suo lavoro riesco a farglielo fare solo quando in document.getElementById('dati1').innerHTML = response; uso "dati1" cioè indico staticamente il nome del div.. a me servirebbe però che quel dati1 fosse dinamico cioè passato al richiamo della funzione handleResponse... posto tutto il codice spero che mgari qualcuno mi possa aiutare..

    function createObject() {
    var tipo_richiesta;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
    tipo_richiesta = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
    tipo_richiesta = new XMLHttpRequest();
    }
    return tipo_richiesta;
    }

    var http = createObject();

    function controlla(valore,div) {
    // add image progress
    var par = window.document;
    var images = par.getElementById(div);
    var new_div = par.createElement('div');
    var new_img = par.createElement('img');
    new_img.src = 'indicator.gif';
    new_div.appendChild(new_img);
    images.appendChild(new_div);
    http.open('get', 'stampa.php?valore='+valore);
    http.onreadystatechange = handleResponse;
    http.send(null);
    }

    function handleResponse() {
    if(http.readyState == 4){
    var response = http.responseText;
    document.getElementById('dati1').innerHTML = response;
    }
    }

  2. #2
    chiedo scusa... ma alla fine ho risolto.. ho creato una variabile globale e grazie a questa ho risolto...

    posto lo script completo nel caso qualcuno volesse usarlo..

    var div_handle;
    function createObject() {
    var tipo_richiesta;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
    tipo_richiesta = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
    tipo_richiesta = new XMLHttpRequest();
    }
    return tipo_richiesta;
    }

    var http = createObject();

    function controlla(valore,div) {
    // add image progress
    var par = window.document;
    var images = par.getElementById(div);
    var new_div = par.createElement('div');
    var new_img = par.createElement('img');
    new_img.src = 'indicator.gif';
    new_div.appendChild(new_img);
    images.appendChild(new_div);
    http.open('get', 'stampa.php?valore='+valore);
    div_handle=div;
    http.onreadystatechange = handleResponse;
    http.send(null);
    }

    function handleResponse() {
    if(http.readyState == 4){
    var response = http.responseText;
    document.getElementById(div_handle).innerHTML = response;
    }
    }

  3. #3
    Utente di HTML.it L'avatar di Xinod
    Registrato dal
    Sep 2000
    Messaggi
    13,649

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.