前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >JS创建表单提交备份

JS创建表单提交备份

作者头像
用户1055830
发布2018-01-18 15:47:40
11.6K0
发布2018-01-18 15:47:40
举报
文章被收录于专栏:飞扬的花生
代码语言:javascript
复制
 //保存
    function saveFT() {
      
        var data = {
            createDate: GetDateStr(0),
            name: $("#txtName").val(),
            gender: "未知",
            mobile: $("#txtTel").val(),
            email1: "null@null.com",
            interested:$("#C2 option:selected").text(),
            buyCarTime: "有购车计划但没决定时间",
            province: $("#A2 option:selected").text(),
            city: $("#A3 option:selected").text(),
            dealerName: $("#ddlDealer option:selected").text(),
            eventCode: "1491550852610",
            memo1: "2017年DAF南区3-4月促销计划",
            memo2: "http://design.haoche.cn/haoche/2017/4/7/fute/index.html",
            source: '好车网_PC'
        }

        var turnForm = document.createElement("form");
        //一定要加入到body中!!
        document.body.appendChild(turnForm);
        turnForm.method = 'post';
        turnForm.acceptCharset = "UTF-8";
        turnForm.action = 'http://www.changanfordclub.com/Media2Ford/json/CommitData.action';
        turnForm.target = 'login2';
        turnForm.enctype = "text/json; charset=UTF-8";


        //创建隐藏表单
        var newElement = document.createElement("input");
        newElement.setAttribute("name", "createDate");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.createDate);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "name");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.name);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "gender");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.gender);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "mobile");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.mobile);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "email1");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.email1);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "interested");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.interested);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "buyCarTime");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.buyCarTime);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "province");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.province);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "city");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.city);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "dealerName");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.dealerName);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "eventCode");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.eventCode);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "memo1");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.memo1);
        turnForm.appendChild(newElement);

        newElement = document.createElement("input");
        newElement.setAttribute("name", "memo2");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.memo2);
        turnForm.appendChild(newElement);


        //新添加Source
        newElement = document.createElement("input");
        newElement.setAttribute("name", "source");
        newElement.setAttribute("type", "hidden");
        newElement.setAttribute("value", data.source);
        turnForm.appendChild(newElement);

        turnForm.submit();

        //   $.post(
        //     "http://www.changanfordclub.com/Media2Ford/json/CommitData.action",
        //     data,
        //     "json",
        //    function (data) {
        //        if (data.success) {

        //        }
        //    }
        //);
        //$.ajax({
        //    type: "POST",
        //    url: "http://www.changanfordclub.com/Media2Ford/json/CommitData.action",
        //    data: data,
        //    dataType: "html",
        //    cache: false,

        //    success: function (data) {
        //    }
        //});
    }
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017-06-07 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档