1. 程式人生 > >jquery動態建立form表單

jquery動態建立form表單

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();
    }