Visualizzazione dei risultati da 1 a 3 su 3

Discussione: Problema con variabili

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2006
    Messaggi
    47

    Problema con variabili

    Nel codice seguente all'interno di un ciclo cerco il nodo "cod" da un file xml e ne scrivo il valore nella var "codice"
    tale valore devo passarlo in post ad un file .asp quando si clicca sul link
    il problema è che quando clicco il valore risualta sempre quello dell'ultimo nodo "cod" e non dell'attuale nodo
    Come posso risolvere?

    Grazie

    Giuseppe

    Codice PHP:
                else if (x[i].childNodes[j].nodeName == 'cod') {
                    var 
    container document.createElement('TD');
                    var 
    theData document.createElement('SPAN');
                    
    theData.className "codice_id";
                    var 
    aHref=document.createElement("a");
                    
    aHref.setAttribute('href','#');
                    
    codice "ID="+x[i].childNodes[j].firstChild.nodeValue
                    
    aHref.onclick = function(){javascript:void(alert(codice)); javascript:void(xmlhttpPost('miaPag.asp'codicericevo_xml));  };    
                    var 
    testo document.createTextNode(" "+x[i].childNodes[j].firstChild.nodeValue); 
                    
    aHref.appendChild(testo);
                    
    theData.appendChild(aHref);
                } 

  2. #2
    L'errore a mio avviso è PRIMA di questo else if
    Posta il pezzo prima!

    Zappa
    [PC:Presario 2515EU][Cpu:P4@2.3GHz][Ram: 512M][HDU:80G@5400 RPM]
    [Wireless:LinkSys][OS: Ubuntu 9.04 - Jaunty Jackalope]

  3. #3
    Utente di HTML.it
    Registrato dal
    Oct 2006
    Messaggi
    47
    Codice PHP:
        for (i=0;i<x.length;i++)
        {
            var 
    row document.createElement('TR');
            
            if (
    tr_bg == 1) { //colorazone righe
                
    row.className "docaltrow";    
                
    tr_bg 0;
            }
            else {
    tr_bg 1;}
            
            for (
    j=0;j<x[i].childNodes.length;j++)
            {
                if (
    x[i].childNodes[j].nodeType != 1) continue;

                if (
    x[i].childNodes[j].nodeName == 'codIB') {
                    var 
    container document.createElement('TD');
                    var 
    theData document.createTextNode(" "+x[i].childNodes[j].firstChild.nodeValue); 
                    
                }

                else if (
    x[i].childNodes[j].nodeName == 'cod') {
                    var 
    container document.createElement('TD');
                    var 
    theData document.createElement('SPAN');
                    
    theData.className "codice_id";
                    var 
    aHref=document.createElement("a");
                    
    aHref.setAttribute('href','#');
                    
    codice "ID="+x[i].childNodes[j].firstChild.nodeValue//da mandare come post
                    
    aHref.onclick = function(){javascript:void(alert(codice)); javascript:void(xmlhttpPost('Miofile.asp'codicericevo_xml));  };    
                    var 
    testo document.createTextNode(" "+x[i].childNodes[j].firstChild.nodeValue); 
                    
    aHref.appendChild(testo);
                    
    theData.appendChild(aHref);
                } 

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 © 2025 vBulletin Solutions, Inc. All rights reserved.