Reputation: 1634
I am using jquery dialog to submit a form to a db and what I would like to do, is, on the beforeclose function, fire an alert to show what they submiited. Problem, is that I am getting 'box' undefined in firebug. I assumed that the variables would work in my code, but obviously not. I would be grateful if someone could check my code to see where I made the error. I shall only post the code thats relevant. Thanks
beforeclose: function (event, ui) {
jAlert("You have successfully editted\n\rBox: "+box+"\n\r"+
"Status: "+status+"\n\r"+
"Size: "+size+"\n\r", 'Box addittion successfull');
$("#f2").html("");
}
The .click part
$('#EB_submit').click(function () {
var submit = $('#EB_submit').val();
var status = $('#EB_status').val();
var id = $('#EB_id').val();
var box = $('#EB_custref').val();
var size = $('#EB_size').val();
var service = $('#EB_service :selected').text();
var address = $('#EB_address :selected').text();
var data = 'submit=' + submit +
'&id=' + id +
'&status=' + status +
'&box=' + box +
'&size=' + size;
Upvotes: 1
Views: 191
Reputation: 14435
Based on what you posted, the var 'box' is local to the click function and unavailable to the dialog function.
var box;
$('#EB_submit').click(function () {
var submit = $('#EB_submit').val();
var status = $('#EB_status').val();
var id = $('#EB_id').val();
box = $('#EB_custref').val();
Here is a fiddle: http://jsfiddle.net/mwUjv/
Upvotes: 2
Reputation: 5002
box is not defined in the beforeclose function. define box as a global variable.
Upvotes: 0