function initRow(questionname,questioncontent,types,re)
{
var table = document.getElementById('tbquestion');
var rowNew = table.insertRow();
var cellNew = rowNew.insertCell();
cellNew.colSpan="8";
cellNew.align="left";
cellNew.innerHTML =""+questionname+"";
if(re != "")
{
cellNew.innerHTML += " 说明:("+re+")";
}
var rowNew1 = table.insertRow();
var s = questioncontent.split('-');
for(var j = 1;j<s.length;j++)
{
var st = s[j].split(',');
for(var k = 0;k<st.length;k++)
{
var option = st[k].split('|');
var cellNew1 = rowNew1.insertCell();
cellNew1.align="left";
if(types == 0)
{
type = "radio";
}
if(types == 1)
{
type ="checkbox";
}
cellNew1.innerHTML="<input name=\"ra\" type=\""+type+"\" id=\"raoption\" />"+option[0];
}
}
}
首先,我创建的radio和checkbox的name都一样。。怎么弄他们不一样?
怎么获取并保存(查看能自动选中)我选中的radio或checkbox和它们后面的文本。。
这是我的获取文本的方法: function GetValue(){
var table = document.getElementById("tbquestion");
var temp=document.getElementsByName("ra");
for (i=0;i <temp.length;i++){
if(temp[i].checked==true){
var d = temp[i].nextSibling.nodeValue;
alert(d);
}
} 但是name 属性不能一样,所以不知道怎么写了。。
各位牛人。。帮帮啦。。分数不多了..下面是后台方法
protected void GetQuestionInfo(int id)
{
DataSet ds = bll_question.getAll("select * from tab_question where wenjuan_name=" + id);
//this.HiddenField1.Value = type;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
string st = "";
string option = "";
string[] str = ds.Tables[0].Rows[i]["ques_content"].ToString().Split('\r');
foreach (string content in str)
{
string[] s = content.Split('\n');
foreach (string c in s)
{
st += c + "|";
}
}
string que_id = ds.Tables[0].Rows[i]["ques_id"].ToString();
DataSet ds1 = bll_question.getAll("select * from tab_question where ques_id=" + Convert.ToInt32(que_id));
string re = ds1.Tables[0].Rows[0]["ques_re"].ToString();
string type = ds1.Tables[0].Rows[0]["ques_type"].ToString();
ClientScript.RegisterStartupScript(ClientScript.GetType(), "aa" + i, "<script>initRow('" + '[' + (i + 1) + ']' + ds.Tables[0].Rows[i]["ques_name"].ToString().Trim() + "','" + st + "','" + type + "','" + re + "');</script>");
}
}
我该怎么获取我选中的值~
自己已搞定