views:

26

answers:

0

function Psend() {

     new Ajax.Request('Handler.ashx',
        {
            method: 'get',
            onSuccess: function(transport) {
                var response = transport.responseText || "no response text";
                //alert("Success! \n\n" + response);
                var obj = response.evalJSON(true);

                for (i = 0; i < 4; i++) {

                    DeCheBX = $('MyDiv').insert(new Element('input', { 'type': 'checkbox', 'id': "Img" + obj[i].Nam, 'value': obj[i].IM, 'onClick': 'SayHi(this,i)' }));
                    document.body.appendChild(DeCheBX);
                    DeImg = $('MyDiv').insert(new Element('img', { 'id': "img" + obj[i].Nam, 'src': obj[i].IM }));
                    document.body.appendChild(DeImg);

                    SayHi = function(x,i) {
                        try {

                            if ($(x).checked == true) {
                                img = "img" + obj[i].Nam;
                                alert(img);
                                $('img').hide();
                            }

                        }


                        catch (e) {
                            alert("error");
                        }

                    };
                }






            },
            onFailure: function() { alert('Something went wrong...') }
        });




}

related questions