qq_35514032 2019-04-22 20:20 采纳率: 0%
浏览 616

js如何获取很多个select里面的optin的值 并且把值求和,传递到后台,我现在只会1个一个的获取求指点1。

检查 计算 人:分 房屋:分
提交 返回

function homsave() { var name = $("#text1").val(), idcode = $("#text2").val(); var remarks = $("#text34").val(), bank = $("#text35").val(); var mtion = $("#text36").val(); $.ajax({ type: "POST", //提交的方法 url:"/business/save", //提交的地址 data:$('#homesave').serialize(),// 序列化表单值 async: false, error: function(request) { //失败的话 alert("Connection error"); }, success: function(data) { //成功 alert(data); //就将返回的数据显示出来 window.location.href="跳转页面" } }); // var name = $("#text1").val(), idcode = $("#text2").val(); // var remarks = $("#text34").val(), bank = $("#text35").val(); // var mtion = $("#text36").val(); // if (remarks == null || remarks == "") { // alert("备注不能为空"); // return; // } // if (bank == null || bank == "") { // $("#text35").val("--"); // } // if (mtion == null || remarks == "") { // $("#text36").val("--"); // } alert(name+idcode) } function jc() { var remarks = $("#text34").val(), bank = $("#text35").val(); var mtion = $("#text36").val(); if (remarks == null || remarks == "") { $("#text34").val("--"); } if (bank == null || bank == "") { $("#text35").val("--"); } if (mtion == null || remarks == "") { $("#text36").val("--"); } } function js() { var text3 = $("#text3").find("option:selected").val(); var text4 = $("#text4").find("option:selected").val(); var text5 = $("#text5").find("option:selected").val(); var text6 = $("#text6").find("option:selected").val(); var text7 = $("#text7").find("option:selected").val(); var text8 = $("#text8").find("option:selected").val(); var text9 = $("#text9").find("option:selected").val(); var text10 = $("#text10").find("option:selected").val(); // var text11 = $("#text11").find("option:selected").val(); var text12 = $("#text12").find("option:selected").val(); var text13 = $("#text13").find("option:selected").val(); var text14 = $("#text14").find("option:selected").val(); var text26 = $("#text26").find("option:selected").val(); var text27 = $("#text27").find("option:selected").val(); var text28 = $("#text28").find("option:selected").val(); var text29 = $("#text29").find("option:selected").val(); var text30 = $("#text30").find("option:selected").val(); var text31 = $("#text31").find("option:selected").val(); var text32 = $("#text32").find("option:selected").val(); var text33 = $("#text33").find("option:selected").val(); var menfen = parseInt(text3)+parseInt(text4)+parseInt(text5)+parseInt(text6) +parseInt(text7)+parseInt(text8)+parseInt(text9)+parseInt(text10) +parseInt(text12)+parseInt(text13)+parseInt(text14); var homefen = parseInt(text26)+parseInt(text27)+parseInt(text28)+parseInt(text29) +parseInt(text30)+parseInt(text31)+parseInt(text32)+parseInt(text33); $("#men").val(menfen); $("#home").val(homefen) }
  • 写回答

1条回答 默认 最新

  • qq_36442647 2019-04-23 11:31
    关注
                var sum = 0;
        $("select").each(function () {
            $(this).children("option:selected").each(function () {
                sum += parseInt($(this).val());
            });
        });
                试一下
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器