when i click on checkbox ,the image should be hiden though i dont make it happen somehow and i can g

Posted by user309381 on Stack Overflow See other posts from Stack Overflow or by user309381
Published on 2010-04-18T21:12:31Z Indexed on 2010/04/18 21:23 UTC
Read the original article Hit count: 248

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...') }
        });




}

© Stack Overflow or respective owner

Related posts about prototypejs

Related posts about javascript-framework