jquery动态创建form表单

时间:2021-05-25 15:17:09
function exportExcel() {
var merchantName = $('#merchantName').val();
var merchantNo = $('#merchantNo').val();
var orderNo = $('#orderNo').val();
var phone = $('#phone').val();
var orderStatus = $('#orderStatusCombobox').combobox('getValue');
var paidStatus = $('#hasPaidCombobox').combobox('getValue');
var refundStatus = $('#hasRefundCombobox').combobox('getValue');
var firstDealStatus = $('#firstDealCombobox').datebox('getValue');
var createDateFrom = $('#createDateFrom').datebox('getValue');
var createDateTo = $('#createDateTo').datebox('getValue');
var opts = $('#orderDetailGrid').datagrid('options');
var params = {
merchantName: merchantName,
merchantNo: merchantNo,
orderNo: orderNo,
phone: phone,
orderStatus: orderStatus,
paidStatus: paidStatus,
refundStatus: refundStatus,
firstDealStatus: firstDealStatus,
createDateFrom: createDateFrom,
createDateTo: createDateTo,
page: opts.pageNumber,
rows: opts.pageSize
};
$("body").append("<form></form>");
$("body").find("form").attr("action", '/yami/backend/order.exportOrderDetails.do');
$("body").find("form").attr("method", "post");
$("body").find("form").attr("style", "display:none");
$.each(params, function (k, v) {
$("body").find("form").append("<input type='text' name='" + k + "' value = '" + v + "'></input>");
});
$("body").find("form").submit();
}