62,073
社区成员
发帖
与我相关
我的任务
分享
<!--多选-->
<%
List<object[]> obj=new List<object[]>();
con.Open();
string sql = "Select TOP 30 * From T_Subject Order By NewID()";
System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand(sql, con);
System.Data.SqlClient.SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
Object[] obj_one = new Object[5];
obj_one[0] = dr["fsubjectid"];
obj_one[1] = dr["fsubjectcontent"];
obj_one[2] = dr["fusbjectstate"];
obj_one[3] = dr["foptionstitle"];
obj_one[4] = dr["fsubjecttype"];
obj.Add(obj_one);
}
con.Close();
for (int i = 0; i < obj.Count; i++)
{
con.Open();
sql = "select * from T_Options where foptionbysubjectid="+obj[i][0];
System.Data.SqlClient.SqlCommand cmd1 = new System.Data.SqlClient.SqlCommand(sql, con);
System.Data.SqlClient.SqlDataReader dr1 = cmd1.ExecuteReader();
List<object[]> obj1 = new List<object[]>();
while (dr1.Read())
{
Object[] obj_one = new Object[4];
obj_one[0] = dr1["foptionsid"];
obj_one[1] = dr1["foptioncontent"];
obj_one[2] = dr1["foptionbysubjectid"];
obj_one[3] = dr1["foptionstitle"];
obj1.Add(obj_one);
}
con.Close();
%>
<div class="questionbox" id="questionbox" >
<%=obj[i][1]%>
</div>
<div class="line"></div>
<div class="answer">
<%
if (int.Parse(obj[i][4].ToString()) == 1)
{
for (int j = 0; j < obj1.Count; j++)
{
%>
<input name="rad1" type="radio" value=""/><%=obj1[j][3]+"."+obj1[j][1]%><br />
<%
}
%>
<%
}
else
{
for (int j = 0; j < obj1.Count; j++)
{
%>
<input name="cx1" type="checkbox" value=""/><%=obj1[j][3]+"."+obj1[j][1] %><br />
<%
}
%>
</div>
<div class="line"></div>
<%
}
%>
<%
}
%>[/b]
$.ajax({
type: "get",
dataType: "json",
url: "ReturnCity.ashx",
data: {
provinceId: $("#s_province").val()
},
success: function (msg) {
$("#s_city").empty(); //清空市区选项
$("#s_county").empty(); //清空县区选项
//$("<option value='-1'>请选择市/区</option>").appendTo("#s_city");
//$("<option value='-1'>请选择位置</option>").appendTo("#s_county");
$.each(msg.returnStr, function (i, n) {
//alert(i);
$("<option value=" + n.cityID + ">" + n.city + "</option>").appendTo("#s_city");
});
changeCity();
},
error: function (msg) {
alert(msg);
}
});
类似这样的,需要Newtonsoft.Json.dll这个dll