Ext.onReady(function() { var results = new Ext.Panel({ border: false, renderTo: 'poll_results', items: [{ border: false, html: '
Which is a better choice for justice in a case of murder in the first degree?
' },{ border: false, html: '
Life without parole (71.57%)
' },{ xtype: 'progress', id: 'results_1_progressbar', border: false, value: '0.71573604060914' },{ border: false, html: '
Death penalty (28.43%)
' },{ xtype: 'progress', id: 'results_2_progressbar', border: false, value: '0.28426395939086' } ], bbar: [{ text: 'Vote Form', id: 'show_form_button', hidden: false, handler: function() { results.hide(); form.show(); } }] }); var form = new Ext.form.FormPanel({ renderTo: 'poll_form', url: '/scripts/poll.js.php', method: 'post', border: false, items: [{ border: false, html: '
Which is a better choice for justice in a case of murder in the first degree?
' },{ xtype: 'radio', hideLabel: true, boxLabel: 'Life without parole', name: 'option', inputValue: 'results_1' }, { xtype: 'radio', hideLabel: true, boxLabel: 'Death penalty', name: 'option', inputValue: 'results_2' } ], bbar: [{ text: 'Vote', hidden: false, handler: function() { form.getForm().submit({ params: { 'action': 'vote', 'id': '4' }, success: function(f, a) { form.hide(); results.show(); Ext.getCmp('show_form_button').hide(); Ext.get('option_1').update(a.result.option_1 + ' (' + a.result.percent_1 + '%)'); Ext.getCmp('results_1_progressbar').updateProgress(a.result.results_1); Ext.get('option_2').update(a.result.option_2 + ' (' + a.result.percent_2 + '%)'); Ext.getCmp('results_2_progressbar').updateProgress(a.result.results_2); } }); } },{ text: 'View Results', handler: function() { form.hide(); results.show(); } }] }); results.hide(); });