View Full Version : MessageBox with a checkbox?

11 Jan 2011, 7:21 AM
Hi, is there a way to a have a checkbox in a message box or would I have to create by own pop-up window?


11 Jan 2011, 7:25 AM
You sure can. The body text of a MessageBox supports HTML, so you could have any element in there. Then your processing function when the user clicks 'Ok' or 'Save' or whatever could check the value of that element.

11 Jan 2011, 7:29 AM
Ahh great, that works. Thanks!

11 Jan 2011, 7:50 AM
Here's a quick example.

title: 'Verification',
msg: 'This feature requires administrator approval. Please <br/>verify this change by checking the box below.<br/><br/><input type="checkbox" id="admin_approve" /> I approve this change',
buttons: Ext.MessageBox.OKCANCEL,
fn: function(btn) {
if( btn == 'ok') {
if (Ext.get('admin_approve').getValue() == 'on'){
Ext.MessageBox.alert('Demo', 'Admin approval acquired');
} else {
Ext.MessageBox.alert('Demo', 'Admin approval not acquired');

26 Mar 2011, 9:39 AM
I was trying this code in Firefox and I was always getting the value 'on' for the checkbox field:

if (Ext.get('admin_approve').getValue() == 'on'){so I changed that line by:

if (document.getElementById('admin_approve').checked){and now it's working fine.