Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Group info
Members: 1059
Language: English
Group categories: Not categorized
More group info »
Recent pages and files
problem with updating the response of an ajax request    

hello. i have a small problem with updating the response after 3 ajax request.

my js scripts that should help me update the reponse are declared in the header of my index.php.

 

function afisinv(i)
    {
        var i;
        var url = 'selectinv.php';
        var mytime = new Date().getTime();
        var data = '?varinv=' + i + '&data=' + mytime;
        //alert (url + data);
        new Ajax.Request (
        url,
        {
            method : 'get',
            parameters : data,
            onSuccess: function(transport)
            {
                var response = transport.responseText;
                $('inv').innerHTML = response;
            }
        }
        )
    }

 

 

after the first ajax request i select some data from mysql, output it in divs etc... + a form w/ input type hidden with data and 2 buttons (which launche the second ajax request)

 

function copiez_inv()
    {
        $('edit_inv').show();
        var url = "copiez_inv.php";
        var varinv = $F('nrinv');
        var data = $F('data');
        var idc = $F('idc');
        var mytime = new Date().getTime();
        //alert (invno + " " + data);
        new Ajax.Request
        (
            url,
            {
                method: 'post',
                parameters: { varinv: varinv, data: data, mytime: mytime, idc:idc},
                onSuccess: function(transport)
                {
                    var response = transport.responseText;
                    $('edit_inv').innerHTML = response;
                    $('inv').hide();
                }
            }
        );
    }


problem is, after the second ajax request, i simply cannot update the values of the inputs by calling the JS scripts declared in the header. Any idea why is this happening? (it acts the same in FF and IE6 or IE7)

 

this is the JS with the problem


var varCount = 1;
    function sterg(poz)
    {

        var varCount = $F('varCount');   
        var poz;
        var ord = 'ord'+poz;
        var serviciu = 'serviciu'+poz;
        var roomnr = $('roomnr'+poz).value;
        var quantity = $('quantity'+poz).value;
        var unitval = $('unitval'+poz).value;
        var total_final = $('total_pozz').value;
        var ce_scad = $('roomnr'+poz).value * $('quantity'+poz).value * $('unitval'+poz).value;
        total_final = parseInt(total_final - (roomnr * quantity * unitval));
        alert (total_final);
        $('total_pozz').value = parseInt(total_final);     
        if ( parseInt(poz) < parseInt(varCount-1) )
        {
            for (j = poz; j < parseInt(varCount-1) ; j++)
            {
                var k = parseInt(j)+1;
                $('serviciu'+j).value = $('serviciu'+k).value;
                $('roomnr'+j).value = $('roomnr'+k).value;
                $('roomtype'+j).value = $('roomtype'+k).value;
                $('quantity'+j).value = $('quantity'+k).value;
                $('um'+j).value = $('um'+k).value;
                $('unitval'+j).value = $('unitval'+k).value;
               
            }
            $('ord'+(varCount-1)).remove();
            $('serviciu'+(varCount-1)).remove();
            $('roomnr'+(varCount-1)).remove();
            $('roomtype'+(varCount-1)).remove();
            $('quantity'+(varCount-1)).remove();
            $('um'+(varCount-1)).remove();
            $('unitval'+(varCount-1)).remove();
            $('but'+(varCount-1)).remove();
            $('pozz'+(varCount-1)).remove();
            varCount--;
            $('varCount').value = varCount;  
        }
        else if (parseInt(poz)  === parseInt(varCount-1))
        {
            $('ord'+poz).remove();
            $('serviciu'+poz).remove();
            $('roomnr'+poz).remove();
            $('roomtype'+poz).remove();
            $('quantity'+poz).remove();
            $('um'+poz).remove();
            $('unitval'+poz).remove();
            $('but'+poz).remove();
            $('pozz'+poz).remove();
            varCount--;
           
            /*    adaugat    */
            $('varCount').value = varCount;
           
            /* ************* */   
        }
        h = 1;   
        for (j = 1; j < (varCount); j++)
        {
                if ($('ord'+j)) { $('ord'+j).value = h; h++; }
        }
    }


it's strange because if i alert the js variables, they are ok, but the input data simply don't update properly

Version: 
1 message about this page
Sep 15 2008 by Niells
Click on http://groups.google.com/group/prototype-core/web/problem-with-updating-the-response-of-an-ajax-request
- or copy & paste it into your browser's address bar if that doesn't
work.
Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google