I am developing a billing system using codeigniter - mysql. I would like to print invoice using window.open() of JavaScript . My code is like below

$(document).ready(function()
{

function invoice()
{
var wind = window.open('','_blank','width=700,height=700,scrollbars=yes,status=yes');

var html = '<input type="button" id="submit_button" onclick="print_invoice();" value="Submit"/>';
$(wind.document.body).html(html);
}

$('#print_invoice').click(invoice);

});

I would like to attach a function in the input button id="submit_button" to save the invoice in database.

Could any one say how can I do that?