web页面中 将几个字段post提交

思路 自己在html中构建form 先根据传入的action构建form的action  然后根据要提交的字段构建form中的元素  最后通过调用form中的按钮提交from表单

方法:
var jsPost = function (action, values) {
        var id = Math.random();
        document.write('<form id="post' + id + '" name="post' + id + '" action="' + action + '" method="post">');
        for (var key in values) {
            document.write('<input type="hidden" name="' + key + '" value="' + values[key] + '" />');
        }
        document.write('</form>');
        document.getElementById('post' + id).submit();
    }

调用

jsPost('/mmsadd/Index', { 'ContactIDList': idlist });

jsPost('/mmsadd/Index', { 'ContactIDList': idlist,'ContactID': id });

原文地址:https://www.cnblogs.com/hucaihao/p/3514808.html