开发者

execute javascript function

Need help with the following JavaScript function.

when I isolate each as if they were separate functions (i.e. to remark out all but one at a time). I do get the expected value alerted.

But when run as block of code only the first value is alerted. Not able to see what I'm doing wrong

function stateChanged(){ 

    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;            

    if (xmlhttp.readyState==4){ 

        var product = document.getElementById ("product");
            for (var i = 0; i < product.childNodes.length; i++) {
                var child = product.childNodes[i];
                if (child.nodeType == 3) {
                     //alert ("The " + i + ". child is a text node. Contents:\n" + child.data);
                    var customerProduct =  product.childNodes[i].nodeValue;
                    alert(customerProduct);   
                }
                else {
                    if (child.nodeType == 1) {
                        var product =  ("The " + i + ". child is an element node. Contents:\n" + child.innerHTML);
                    }
                }
            }

         var model = document.getElementById ("model");
            for (var i = 0; i < model.childNodes.length; i++) {
                var child = model.childNodes[i];
                if (child.nodeType == 3) {
                     //alert ("The " + i + ". child is a text node. Contents:\n" + child.data);
                    var productModel =  model.childNodes[i].nodeValue;
                    alert(productModel);   
                }
                else {
                    if (child.nodeType == 1) {
                        var model =  ("The " + i + ". child is an element node. Contents:\n" + child.innerHTML);
                    }
                }
            }

         var serial = document.getElementById ("serial");
            for (var i = 0; i < serial.childNodes.length; i++) {
                var child = serial.childNodes[i];
                if (child.nodeType == 3) {
                     //alert ("The " + i + ". child is a text node. Contents:\n" + child.data);
                    var productSerial =  serial.childNodes[i].nodeValue;
                    alert(productSerial);   
                }
                else {
                    if (child.nodeType == 1) {
                        var serial =  ("The " + i + ". child is an element node. Contents:\n" + child.innerHTML);
                    }
                开发者_开发技巧}
            }

         var computer = document.getElementById ("computer");
            for (var i = 0; i < computer.childNodes.length; i++) {
                var child = computer.childNodes[i];
                if (child.nodeType == 3) {
                     //alert ("The " + i + ". child is a text node. Contents:\n" + child.data);
                    var computer =  computer.childNodes[i].nodeValue;
                    alert(computer);   
                }
                else {
                    if (child.nodeType == 1) {
                        var computer =  ("The " + i + ". child is an element node. Contents:\n" + child.innerHTML);
                    }
                }
            } 

         var os = document.getElementById ("os");
            for (var i = 0; i < os.childNodes.length; i++) {
                var child = os.childNodes[i];
                if (child.nodeType == 3) {
                     //alert ("The " + i + ". child is a text node. Contents:\n" + child.data);
                    var os =  os.childNodes[i].nodeValue;
                    alert(os);   
                }
                else {
                    if (child.nodeType == 1) {
                        var os =  ("The " + i + ". child is an element node. Contents:\n" + child.innerHTML);
                    }
                }
            }
    } 
 }

appreciated. ussteele

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜