JSON 传值
来源:互联网 发布:java求质数 编辑:程序博客网 时间:2024/06/03 22:05
JS:
<SCRIPT LANGUAGE="JavaScript">
$(document).ready(function () {
$("#btnjiaojuan").click(function () {
var dx = $("input:checked");
if (dx.length >= 1 && dx.length <=9)
{ alert("还有未做完的题"); return false; }
else
{
if (confirm("确定交卷?")) {
//alert("正在交卷,请稍后");
var xz = "";
var radios = document.getElementsByClassName("danx");
for(var i=0;i<radios.length;i++)
{
if(radios[i].checked==true)
{
xz += radios[i].value + ",";
}
}
var ti = "";
$("h4").each(function(i) {
ti += this.id+",";
})
var xuanze = new Array();
xuanze = xz.split(',');
for (i = 0; i < xuanze.length ; i++) {
xuanze[i]; //分割后的字符输出
}
var th = new Array();
th = ti.split(',');
for (i = 0; i < th.length ; i++) {
th[i]; //分割后的字符输出
}
var data1 = '{"persons":['
for (var i = 0; i < th.length-1; i++) {
if (i == th.length-2) {
data1 += '{"tihao":"' + th[i] + '","daan":"' + xuanze[i] + '"}';
}
else {
data1 += '{"tihao":"' + th[i] + '","daan":"' + xuanze[i] + '"},';
}
}
data1 += ']}';
//alert(data1);
$.ajaxSettings.async = false;
$.ajax(
{
type: "POST",
url: "../../Handlerdanxuan.ashx",
data: "t="+data1,
dataType: "text",
success: function (data) {
if (data == 1)
{
alert("交卷成功");
return false;
}
else
{
alert("交卷失败");
}
return false;
},
error: function (err) {
alert("错误:" + err);
}
});
return false;
}
else {
return false;
}
}
});
});
</SCRIPT>
<body>
<div class="danxuantm">
<h4 id="@dr[0]"><strong>@i、@dr[5]</strong></h4>
<p>
<input tabindex="1" type="radio" id="@i-minimal-radio-1" name="@dr[0]-danxuan" onclick="checkedThis(this);" value="A" class="danx">
A.@dr[1]
</p>
<P>
<input tabindex="2" type="radio" id="@i-minimal-radio-2" name="@dr[0]-danxuan" onclick="checkedThis(this);" value="B" class="danx">
B.@dr[2]
</P>
<P>
<input tabindex="3" type="radio" id="@i-minimal-radio-3" name="@dr[0]-danxuan" onclick="checkedThis(this);" value="C" class="danx">
C.@dr[3]
</P>
<P>
<input tabindex="4" type="radio" id="@i-minimal-radio-4" name="@dr[0]-danxuan" onclick="checkedThis(this);" value="D" class="danx">
D.@dr[4]
</P>
</div>
<button type="submit" id="btnjiaojuan" name="btnjiaojuan" value="交 卷" class="btn">交 卷</button>
</body>
一般处理程序:
JObject a = JObject.Parse(ts);
- json传值
- json传值
- JSON 传值
- Json
- JSON
- JSON
- JSON
- json
- JSON
- JSON
- json
- Json
- json
- JSON
- json
- json
- JSON
- json
- 7 java se(7)----网络编程(Socket编程)
- 洛谷P1156 垃圾陷阱
- 99%的人都会答错的js面试题
- python数据结构学习笔记-2016-10-28-02-使用链表实现稀疏矩阵
- 郝斌的C语言基础 017
- JSON 传值
- Unity协同详解以及与多线程的区别使用
- 蓝牙核心技术概述(三): 蓝牙协议规范(射频、基带链路控制、链路管理)
- SQL聚集函数
- 1072. Gas Station
- HDOJ 4324 Triangle LOVE (三角恋,待解决)
- java synchronized详解
- 安卓小项目之天气预报
- Android开发中的问题总结