Hi!
I´m trying to make a dialog box , where you can press ok or cancel.
How do i set the function so that when a user press ok it returns
true? I'm new to javascript an jQuery so bare with me but this is what
i got so far...
function dialogBox(type,blockUi,heading,message) {
var result;
var signImg;
var buttons;
var ok = '<div><input type="button" id="okBtn" value="Ok" /></div>';
var cancel = '<div><input type="button" id="cancelBtn"
value="Cancel" /></div>';
//warning dialogbox
if (type == 'warning' || type == '') {
signImg='_img/signs/warning.png';
buttons = ok + cancel;
}
//Info dialogbox
else if (type == 'info') {
signImg = '_img/signs/info.png';
buttons = ok;
}
//Fatal dialogbox
else {
signImg = '_img/signs/error.png';
buttons = ok;
}
//Create dialogbox
function dialogBoxCreation() {
$('<div id="dialogBox"><img src="'+signImg+'" alt="sign" /
><h3>' + heading + '</h3><p>'+message+'</p>'+buttons+'</div>')
.appendTo('body')
.center()
.hide()
.fadeIn();
}
dialogBoxCreation();
//BlockUi
if (blockUi=='yes') {
$('<div id="dialogBg"></div>').height($('body').height()).width
('100%').css({
'position': 'absolute',
'background': '#000',
'opacity': '0.6',
'z-index': '1'
}).prependTo('body').fadeIn();
}
$('#okBtn').click(function() {
$('#dialogBox,#dialogBg').fadeOut(function() {
$('#dialogBox').remove();
$('#dialogBg').remove();
});
});
$('#noBtn').click(function() {
$('#dialogBox,#dialogBg').fadeOut(function() {
$('#dialogBox').remove();
$('#dialogBg').remove();
});
});
}
Thanks in advance
George