• 截取动态获取字符串,并在对应位置替换特殊符号、下拉框


    success:function(data){
      var dataObj = JSON.parse(data);
      var tanchuHtml = "";
      for (var i = 0; i < dataObj.R.length; i++) {
        dataObj.RADDIAGNOSIS = dataObj.R[i].RADDIAGNOSIS;//变量相等
        dataObj.RADMANIFEA = dataObj.R[i].RADMANIFEA;//变量相等

        //替换[?]为__
        if (dataObj.R[i].RADMANIFEA.indexOf('[?]×[?]' || '[?]') > 0 || dataObj.R[i].RADDIAGNOSIS.indexOf('[?]×[?]' || '[?]') > 0) {
          //a.1
          aRADMANIFEA = dataObj.R[i].RADMANIFEA.replace(/([?])/g,'__');
          var bRADMANIFEA = aRADMANIFEA.replace(/[|]/g,"");
          dataObj.RADMANIFEA = bRADMANIFEA.replace(/__/g,'<input class="keyinput" maxlength="4" type="number" style="30px;border:0;border-bottom:1px solid #ccc;">');
          //b.1
          aRADDIAGNOSIS = dataObj.R[i].RADDIAGNOSIS.replace(/([?])/g,'__');
          var bRADDIAGNOSIS = aRADDIAGNOSIS.replace(/[|]/g,"");
          dataObj.RADDIAGNOSIS = bRADDIAGNOSIS.replace(/__/g,'<input class="keyinput" maxlength="4" type="number" style="30px;border:0;border-bottom:1px solid #ccc;">');
        }

        //替换{右侧|左侧|双侧}为对应下拉框
        if(dataObj.R[i].RADMANIFEA.indexOf('}') > 0 || dataObj.R[i].RADDIAGNOSIS.indexOf('}') > 0) { 
          var str = dataObj.RADMANIFEA;
          var str2 = dataObj.RADDIAGNOSIS;
          var thisId = 0;//默认从0开始
          //a.2
          var result = str.replace(/[^{)]+(?=})/g, function(item){
            thisId++;//动态累加
            var itemResult = '<select class="+'class'+thisId+" onchange="change(this);">';
            var selectData = item.split("|");
            $.each(selectData,function(i,v){
              itemResult+="<option value='"+v+"'>"+v+"</option>";
            })
          itemResult+="</select>"
          return itemResult;
        });//替换下拉框
        dselect = result.replace(/({)/g,'');//去除{
        dataselect = dselect.replace(/(})/g,'');//去除}
        //b.2
        var result2 = str2.replace(/[^{)]+(?=})/g, function(item){
          thisId++;
          var itemResult2 = '<select class="+'class'+thisId+" onchange="change(this);">';
          var selectData2 = item.split("|");
          $.each(selectData2,function(i,v){
            itemResult2+="<option>"+v+"</option>"; 
          })
          itemResult2+="</select>"
          return itemResult2; 
        });
        dselect2 = result2.replace(/({)/g,'');
        dataselect2 = dselect2.replace(/(})/g,'');

        dataObj.RADDIAGNOSIS = dataselect2;//各自赋值
        dataObj.RADMANIFEA = dataselect;//各自赋值 
      }
      tanchuHtml += '<div class="tanchu_p"><h5>影像学表现:</h5><div><input class="ainput" type="checkbox" checked="checked"><p         class="img_one">'+dataObj.RADDIAGNOSIS+'</p></div></div>'
      tanchuHtml += '<div class="tanchu_p"><h5>影像学意见:</h5><div><input class="ainput" type="checkbox" checked="checked"><p       class="img_two">'+dataObj.RADMANIFEA+'</p></div></div>'
      $('.tanchuAll').html(tanchuHtml);
      };
      var top=($(window).height()-$(".tanchu").height())/2;//让其弹出层在中间显示
      var left=($(window).width()-$(".tanchu").width())/2-128;//让其弹出层在中间显示
      var scrollTop=$(document).scrollTop();
      var scrollLeft=$(document).scrollLeft();
      $(".tanchu").css({position:'absolute', 'top':top + scrollTop, 'left':left + scrollLeft}).stop().fadeIn()//弹出层显示 
      $(".mask").show();//遮罩层显示
      $('body').addClass('current_body'); 
    },

    ゛Toly★小饼干ゞ
  • 相关阅读:
    java集合类散列表
    记北京挤地铁
    是你的努力,吗?
    letswave-脑电数据处理流程总记
    赵丽颖结婚了,分析下网友评论
    自动线性回归
    ggplot2+treemapify了解一下?
    样本方差的性质及其应用
    5 域名
    4 HTTP的“四层”和“七层”
  • 原文地址:https://www.cnblogs.com/rockyan/p/7244583.html
Copyright © 2020-2023  润新知