for (var j = 0; j < 9; j++) {
eval("if (datas[i].b" + j + " == '1') { b[j-1] = 1; }");
eval("if (datas[i].c" + j + " == '1') { c[j-1] = 1; }");
eval("if (datas[i].d" + j + " == '1') { d[j-1] = 1; }");
eval("if (datas[i].e" + j + " == '1') { e[j-1] = 1; }");
}

效果如下

 //                    if (datas[i].a1 == '1') { a[0] = 1; }
// if (datas[i].a2 == '1') { a[1] = 1; }
// if (datas[i].a3 == '1') { a[2] = 1; }
// if (datas[i].a4 == '1') { a[3] = 1; }
// if (datas[i].a5 == '1') { a[4] = 1; }
// if (datas[i].a6 == '1') { a[5] = 1; }
// if (datas[i].a7 == '1') { a[6] = 1; }
// if (datas[i].a8 == '1') { a[7] = 1; } // if (datas[i].b1 == '1') { b[0] = 1; }
// if (datas[i].b2 == '1') { b[1] = 1; }
// if (datas[i].b3 == '1') { b[2] = 1; }
// if (datas[i].b4 == '1') { b[3] = 1; }
// if (datas[i].b5 == '1') { b[4] = 1; }
// if (datas[i].b6 == '1') { b[5] = 1; }
// if (datas[i].b7 == '1') { b[6] = 1; }
// if (datas[i].b8 == '1') { b[7] = 1; } // if (datas[i].c1 == '1') { c[0] = 1; }
// if (datas[i].c2 == '1') { c[1] = 1; }
// if (datas[i].c3 == '1') { c[2] = 1; }
// if (datas[i].c4 == '1') { c[3] = 1; }
// if (datas[i].c5 == '1') { c[4] = 1; }
// if (datas[i].c6 == '1') { c[5] = 1; }
// if (datas[i].c7 == '1') { c[6] = 1; }
// if (datas[i].c8 == '1') { c[7] = 1; } // if (datas[i].d1 == '1') { d[0] = 1; }
// if (datas[i].d2 == '1') { d[1] = 1; }
// if (datas[i].d3 == '1') { d[2] = 1; }
// if (datas[i].d4 == '1') { d[3] = 1; }
// if (datas[i].d5 == '1') { d[4] = 1; }
// if (datas[i].d6 == '1') { d[5] = 1; }
// if (datas[i].d7 == '1') { d[6] = 1; }
// if (datas[i].d8 == '1') { d[7] = 1; } // if (datas[i].e1 == '1') { e[0] = 1; }
// if (datas[i].e2 == '1') { e[1] = 1; }
// if (datas[i].e3 == '1') { e[2] = 1; }
// if (datas[i].e4 == '1') { e[3] = 1; }
// if (datas[i].e5 == '1') { e[4] = 1; }
// if (datas[i].e6 == '1') { e[5] = 1; }
// if (datas[i].e7 == '1') { e[6] = 1; }
// if (datas[i].e8 == '1') { e[7] = 1; }

剩下的自己发挥了

js字符拼接的更多相关文章

  1. 在js中拼接<a>标签,<a>标签中含有onclick事件,点击无法触发该事件

    我们在<a>标签中添加事件一般是onclick="editUser()" 这样添加,在html页面上是行的通的 但是如何你是在js中拼接<a>标签并在< ...

  2. js中拼接HTML方式方法及注意事项

    博主原创:未经博主允许,不得转载 在前端应用中,经常需要在js中动态拼接HTML页面,比如应用ajax进行局部刷新的时候,就需要在js中拼接HTML页面. 主要规则是将HTML页面的标签拼接为标签字符 ...

  3. 【jQuery】JS中拼接URL发送GET请求的中文、特殊符号的问题

    > 参考的优秀文章 jQuery ajax - param() 方法 经常,我们需要在JS中拼接URL然后以GET形式提交请求.如果遇到中文.特殊符号则需要作各种处理. jQuery有一个方法非 ...

  4. 在oracle中,group by后将字符拼接,以及自定义排序

    1.在oracle中,group by后将字符拼接.任务:在学生表中,有studentid和subject两个字段.要求对studentid进行group by分组,并将所选科目拼接在一起.oracl ...

  5. html转js字符串拼接

    https://www.bejson.com/convert/html_js/ html转js字符串拼接

  6. 【Java】字符拼接成字符串的注意点

    这两天敲代码的时候,偶然间发现一个好玩的事情,分享一下,记录一下. 该段代码主要是:先产生的几个整数,把整数转换成对应的字符,最后的字符拼接成字符串,在把字符拼接成字符串的时候,个人因为偷懒使用+号进 ...

  7. js字符操作

    js字符串方法预览: fromCharCode(num1, num2,,,), charAt(), charCodeAt(), length, split(''), slice(start, end? ...

  8. 如何用js定义数组,用js来拼接json字段

    定义js数组的方式有: var arr = (); var arr = []; var arr = new Array(); 如何拼接成一个json字段. <!DOCTYPE HTML PUBL ...

  9. js字符转换成整型 parseInt()函数规程Number()函数

    今天在做一个js加法的时候,忘记将字符转换成整型,导致将加号认为是连接符,  在运算前要先对字符井行类型转换,使用parseInt()函数   使用Number()将字符转换成int型效果更好

随机推荐

  1. leetcode刷题全纪录(持续更新)

    2.Add Two Numbers 原题链接https://leetcode.com/problems/add-two-numbers/ AC解: public ListNode addTwoNumb ...

  2. frame里的链接跳转

    <a href="javascript:parent.location='index_frame.html';void(0);">索引</a> <a ...

  3. codeforces #369div2 B. Chris and Magic Square

    题目:在网格某一处填入一个正整数,使得网格每行,每列以及两条主对角线的和都相等 题目链接:http://codeforces.com/contest/711/problem/B 分析:题目不难,找到要 ...

  4. angularjs 嵌套控制器,子控制器访问父控制器

    <pre> http://www.lovelucy.info/understanding-scopes-in-angularjs.html http://blog.csdn.net/jfk ...

  5. ThinkPHP 3.2.3(二)配置

    一.配置格式 1.PHP数组定义 默认所有配置文件的定义格式均采用返回PHP数组的方式,配置参数不区分大小写. 如果使用二维数组来配置更多的信息,则二级参数配置区分大小写.格式为: //项目配置文件r ...

  6. Visual Studio Code中文文档(一)-快速入门

    Visual Studio Code是一个轻量级但是十分强大的源代码编辑器,重要的是它在Windows, OS X 和Linux操作系统的桌面上均可运行.Visual Studio Code内置了对J ...

  7. STEP模块——电子钟

    原理 显示时分秒(日期也可以加上),两个按键调节时间 原理图 代码 /*---------------------------------------------------------------- ...

  8. Java Mysql分页显示

    public class View { private int currentPage; private int pageSize; private int recordCount; public V ...

  9. struts文件上传、文件下载

    文件上传 如果在表单中上传文件,表单的enctype属性为multipart/form-data struts默认上传文件大小为2M,如果需要修改,在配置文件中设置 <constant name ...

  10. gif显示

    public void gifplay(string path,ref Panel panel) { try{ Bitmap animatedGif = new Bitmap(path ); Grap ...