for (i = 0; i < int.Parse(aa); i++)
{
if ( i == 0)
{
tr = new TableRow();
tc = new TableCell();
tc.ID = "Label"+ i.ToString();
cell = new TableCell();
tc1 = new TextBox();
tc1.ID = "TextBox" + i.ToString();
tc1.Columns = 10;
//tc1.Font.Size= 12;
//tc1.Font.Bold = true;
//tc1.Height = 20;
tc1.CssClass = "c_textbox";
tc.CssClass = "c_label";
tc1.Text = ds_Yuan_payrollsEdit.Tables["T_Yuan_payrollsEdit"].Rows[i][2].ToString();
//tc.Font.Bold = false;
//tc.Font.Size = 12;
tc.Text = ds_Yuan_payrollsEdit.Tables["T_Yuan_payrollsEdit"].Rows[i][1].ToString() + ": ";
tr.Cells.Add(tc);
cell.Controls.Add(tc1);
tr.Cells.Add(cell);
Table1.Rows.Add(tr);
tc1.Attributes.Add("onkeydown", "return CheckInput(this.value,this.id)");
}通过上面的代码 自动生成 Label0, Label1 ... ,Text0,Text1,Text2 ... 这些控件 并添加了onkeydown 这个事件 问下在javascript的 CheckInput 中 如何才能读取和设置它们的值。谢谢
function CheckInput(val,id) {
}
{
if ( i == 0)
{
tr = new TableRow();
tc = new TableCell();
tc.ID = "Label"+ i.ToString();
cell = new TableCell();
tc1 = new TextBox();
tc1.ID = "TextBox" + i.ToString();
tc1.Columns = 10;
//tc1.Font.Size= 12;
//tc1.Font.Bold = true;
//tc1.Height = 20;
tc1.CssClass = "c_textbox";
tc.CssClass = "c_label";
tc1.Text = ds_Yuan_payrollsEdit.Tables["T_Yuan_payrollsEdit"].Rows[i][2].ToString();
//tc.Font.Bold = false;
//tc.Font.Size = 12;
tc.Text = ds_Yuan_payrollsEdit.Tables["T_Yuan_payrollsEdit"].Rows[i][1].ToString() + ": ";
tr.Cells.Add(tc);
cell.Controls.Add(tc1);
tr.Cells.Add(cell);
Table1.Rows.Add(tr);
tc1.Attributes.Add("onkeydown", "return CheckInput(this.value,this.id)");
}通过上面的代码 自动生成 Label0, Label1 ... ,Text0,Text1,Text2 ... 这些控件 并添加了onkeydown 这个事件 问下在javascript的 CheckInput 中 如何才能读取和设置它们的值。谢谢
function CheckInput(val,id) {
}
document.getElementById("id").value 取值
for (i = 0; i < 5; i++) {
var text_value = "document.getElementById(\"ctl00_ContentPlaceHolder1_textid" + i + "\").value";
var sum_js + = text_value;
}
alert(sum_js);就报错了 因为 那个控件的id号 是自动+1的 我问下 该如何修改 顺便问下 我要看某个控件的ID 我应该如何写?