博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
js实现获取值传到input里边
阅读量:6760 次
发布时间:2019-06-26

本文共 2990 字,大约阅读时间需要 9 分钟。

 
<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
<
html
xmlns
="http://www.w3.org/1999/xhtml"
>
<
head
>
<
meta
http-equiv
="Content-Type"
content
="text/html; charset=utf-8"
>
<
title
>
Document
</
title
>
<
style
>
</
style
>
<
script
>
function
checkAll(e, itemName, thisValue){
var
target
=
document.getElementById(
'
arrayid
'
);
var
targetValue
=
target.value;
var
inputs
=
document.getElementsByName(itemName);
if
(e.checked
==
true
) {
targetValue
+=
thisValue
+
'
,
'
;
}
else
{
targetValue
=
targetValue.replace(thisValue
+
'
,
'
,
''
);
}
target.value
=
targetValue;
for
(
var
i
=
0
; i
<
inputs.length; i
++
){
inputs[i].checked
=
e.checked;
}
}
</
script
>
</
head
>
<
body
>
<
form
>
<
p
>
<
input
type
="checkbox"
value
="1001"
name
="1001"
id
="1001"
onclick
="checkAll(this, 'mk1001', '1001')"
>
<
label
for
="1001"
>
复选1
</
label
>
<
input
name
="mk1001"
type
="checkbox"
id
="mk1001"
value
="1"
/>
<
input
name
="mk1001"
type
="checkbox"
id
="mk1002"
value
="2"
/>
<
input
name
="mk1001"
type
="checkbox"
id
="mk1003"
value
="3"
/>
<
input
name
="mk1001"
type
="checkbox"
id
="mk1004"
value
="4"
/>
<
input
name
="mk1001"
type
="checkbox"
id
="mk1005"
value
="5"
/>
</
p
>
<
p
>
<
input
type
="checkbox"
value
="1002"
name
="1002"
id
="1002"
onclick
="checkAll(this, 'mk1002', '1002')"
>
<
label
for
="1002"
>
复选2
</
label
>
<
input
name
="mk1002"
type
="checkbox"
id
="mk1001"
value
="6"
/>
<
input
name
="mk1002"
type
="checkbox"
id
="mk1002"
value
="7"
/>
<
input
name
="mk1002"
type
="checkbox"
id
="mk1003"
value
="8"
/>
<
input
name
="mk1002"
type
="checkbox"
id
="mk1004"
value
="9"
/>
<
input
name
="mk1002"
type
="checkbox"
id
="mk1005"
value
="10"
/>
</
p
>
<
p
>
<
input
type
="checkbox"
value
="1003"
name
="1003"
id
="1003"
onclick
="checkAll(this, 'mk1003', '1003')"
>
<
label
for
="1003"
>
复选3
</
label
>
<
input
name
="mk1003"
type
="checkbox"
id
="mk1001"
value
="11"
/>
<
input
name
="mk1003"
type
="checkbox"
id
="mk1002"
value
="12"
/>
<
input
name
="mk1003"
type
="checkbox"
id
="mk1003"
value
="13"
/>
<
input
name
="mk1003"
type
="checkbox"
id
="mk1004"
value
="14"
/>
<
input
name
="mk1003"
type
="checkbox"
id
="mk1005"
value
="15"
/>
</
p
>
<
p
>
<
input
type
="checkbox"
value
="1004"
name
="1004"
id
="1004"
onclick
="checkAll(this, 'mk1004', '1004')"
>
<
label
for
="1004"
>
复选4
</
label
>
<
input
name
="mk1004"
type
="checkbox"
id
="mk1001"
value
="11"
/>
<
input
name
="mk1004"
type
="checkbox"
id
="mk1002"
value
="12"
/>
<
input
name
="mk1004"
type
="checkbox"
id
="mk1003"
value
="13"
/>
<
input
name
="mk1004"
type
="checkbox"
id
="mk1004"
value
="14"
/>
<
input
name
="mk1004"
type
="checkbox"
id
="mk1005"
value
="15"
/>
</
p
>
<
p
>
请把复选1,2,3的值传到以下的框中,中间以,号分隔
</
p
>
<
p
>
<
input
type
="text"
id
="arrayid"
/>
</
p
>
</
form
>
</
body
>
</
html
>
用js实现获取值传到input里边。
本文转自豪情博客园博客,原文链接:http://www.cnblogs.com/jikey/archive/2009/12/15/1624669.html,如需转载请自行联系原作者
你可能感兴趣的文章
不吹不擂,你想要的Python面试都在这里了【315+道题】
查看>>
电商数据库表设计
查看>>
深入理解virtual/new/override 这些关键字的意义
查看>>
Mysql存储过程包括事务,且传入sql数据运行
查看>>
[zz]开源点评:ZeroMQ简介
查看>>
16个 html5 框架
查看>>
用WinSock实现HTTP的GET - Unicorn - 博客频道 - CSDN.NET
查看>>
CentOS修改系统时间
查看>>
编写一个主函数 main,使用两个值作为实参,并输出它们的和。
查看>>
3D打印机切片与控制软件
查看>>
PHP empty、isset、isnull的区别
查看>>
数字按照不同格式转换成字符串
查看>>
__weak如何实现目标值自己主动设置nil的
查看>>
thttpd增加gzip压缩响应报文体功能,以减少传输数据量
查看>>
Windows下搭建IOS开发环境(一)
查看>>
linux 网络协议分析---3
查看>>
如何将SVN patch的修改做成old&new文件
查看>>
script加载文件
查看>>
统计学常见分布、概念
查看>>
java的PrintStream(打印输出流)详解(java_io)
查看>>