js字符拼接
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字符拼接的更多相关文章
- 在js中拼接<a>标签,<a>标签中含有onclick事件,点击无法触发该事件
我们在<a>标签中添加事件一般是onclick="editUser()" 这样添加,在html页面上是行的通的 但是如何你是在js中拼接<a>标签并在< ...
- js中拼接HTML方式方法及注意事项
博主原创:未经博主允许,不得转载 在前端应用中,经常需要在js中动态拼接HTML页面,比如应用ajax进行局部刷新的时候,就需要在js中拼接HTML页面. 主要规则是将HTML页面的标签拼接为标签字符 ...
- 【jQuery】JS中拼接URL发送GET请求的中文、特殊符号的问题
> 参考的优秀文章 jQuery ajax - param() 方法 经常,我们需要在JS中拼接URL然后以GET形式提交请求.如果遇到中文.特殊符号则需要作各种处理. jQuery有一个方法非 ...
- 在oracle中,group by后将字符拼接,以及自定义排序
1.在oracle中,group by后将字符拼接.任务:在学生表中,有studentid和subject两个字段.要求对studentid进行group by分组,并将所选科目拼接在一起.oracl ...
- html转js字符串拼接
https://www.bejson.com/convert/html_js/ html转js字符串拼接
- 【Java】字符拼接成字符串的注意点
这两天敲代码的时候,偶然间发现一个好玩的事情,分享一下,记录一下. 该段代码主要是:先产生的几个整数,把整数转换成对应的字符,最后的字符拼接成字符串,在把字符拼接成字符串的时候,个人因为偷懒使用+号进 ...
- js字符操作
js字符串方法预览: fromCharCode(num1, num2,,,), charAt(), charCodeAt(), length, split(''), slice(start, end? ...
- 如何用js定义数组,用js来拼接json字段
定义js数组的方式有: var arr = (); var arr = []; var arr = new Array(); 如何拼接成一个json字段. <!DOCTYPE HTML PUBL ...
- js字符转换成整型 parseInt()函数规程Number()函数
今天在做一个js加法的时候,忘记将字符转换成整型,导致将加号认为是连接符, 在运算前要先对字符井行类型转换,使用parseInt()函数 使用Number()将字符转换成int型效果更好
随机推荐
- 当父级是body时,子元素设置position:absolute;定位是根据body还是html呢?
position:absolute 元素相对最近的 position 为 absolute / relative / fixed 的祖先元素(包含块)定位,如果没有这样的祖先元素,则以初始包含块进行定 ...
- 4.AE中的缩放,书签
1.书签 private void textBox1_TextChanged(object sender, EventArgs e) { if (txtBookmark.Text == "& ...
- 重写TextField Rect 改变显示位置
很简单很常用的一些东西,希望给需要的人帮助. 效果图如下: 自定义textField init() { super.init(frame: CGRect(x: , y: , width: yourWi ...
- PLL输出怎么不能配置成我想要的时钟
如下图,我的clk_out7想配置成160M,十几输出变为了150M
- [转]用CSS给SVG <use>的内容添加样式
来源:http://www.w3cplus.com/svg/styling-svg-use-content-css.html?utm_source=tuicool&utm_medium=ref ...
- 16061701(地图灯光编译Beast报错)
[目标] 地图灯光编译报错 [思路] 1 我自己测c2_cwd_rt 附件为当时log 2 ExampleGame\BeastCache\PersistentCache 3 重新删除掉BeastCac ...
- Volley的GET和POST方法
首先记得加上权限 <uses-permission android:name="android.permission.INTERNET"/> XML代码 <?xm ...
- bzoj 3504: [Cqoi2014]危桥
#include<cstdio> #include<iostream> #include<cstring> #define M 100009 #define inf ...
- 【 2013 Multi-University Training Contest 8 】
HDU 4678 Mine 对于每个空白区域,求SG值. 最后异或起来等于0,先手必败. #pragma comment(linker,"/STACK:102400000,102400000 ...
- 同表复制修改日期的procedure
同表复制数据,让其日期增加 算出总共的天数,用group by 分类后的. space 提前求出第一块数据的总和 sum = select count(*) from tbl_event; 固定操作第 ...