views:

26

answers:

0

I am wanting to use two button form and created the following which works. It however breaks any other events on the page but I can't figure out why. Is there a better way?

        window.addEvent('domready', function() {
        $('vote1').addEvent('click',function() {  
            new Element('input', { 
                    'type': 'hidden', 
                    'name': 'winner', 
                    'id': 'vote1id', 
                    'value': 'vote1' 
                }).inject($('voterform'));
            $('vote_wrapper').setStyle('display','none');
        });

        $('vote2').addEvent('click',function() { 
            new Element('input', { 
                    'type': 'hidden', 
                    'name': 'winner', 
                    'id': 'vote2id', 
                    'value': 'vote2' 
                }).inject($('voterform'));
            $('vote_wrapper').setStyle('display','none');   
        });

        $('voterform').addEvent('submit', function(e) {
            e.stop();
            var log = $('v_wrapper').empty().addClass('loader');
            this.set('send', {onComplete: function(response) { 
                log.removeClass('loader');
                $('v_wrapper').set('html', response).set("tween", {duration: 2500}).setOpacity(0).fade(1);
            }});
            this.send();
        });
    });