PDA

View Full Version : مشکل در فیلدهای جدول داینامیک



محمد هدایتی
سه شنبه 26 اردیبهشت 1391, 09:12 صبح
من یک جدول داینامیک دارم که ستون اولش یک checkbox و ستون های بعدی یه سری اطلاعات که از database می یاد حالا می خوام وقتی کاربر روی checkbox کلیک کرد اون سطر انتخاب بشه بتونه فقط اطلاعات اون سطر خاص و ویرایش کنه ، ولی نمی دونم چه جوری باید این کارو کرد ؟ اینم کد جدولم

function start() {
var mybody = document.getElementsByTagName("body")[0];
mytable = document.createElement("table");
mytablebody = document.createElement("tbody");
var nrRows = 11;
var cell;
for(var j = 0; j < nrRows; j++)
{
mycurrent_row = document.createElement("tr");
for(var i = 0; i < 9; i++)
{
if (i==0)
{ mycurrent_cell = document.createElement("td");
mycurrent_txtbox = document.createElement("input");
mycurrent_txtbox.setAttribute('type',"checkbox");

mycurrent_txtbox.setAttribute('onClick',"show();");
mycurrent_txtbox.setAttribute('id',"box1");
mycurrent_txtbox.setAttribute('name',"box1");
mycurrent_cell.appendChild(mycurrent_txtbox);
mycurrent_row.appendChild(mycurrent_cell);
}
else if (i==1)
{
mycurrent_cell = document.createElement("td");
mycurrent_row.appendChild(mycurrent_cell);
mycurrent_cell.appendChild(document.createTextNode (j));
mycurrent_row.appendChild(mycurrent_cell);
}
else if ( i==6 || i==8 )
{
mycurrent_cell = document.createElement("td");
mycurrent_txtbox = document.createElement("input");
mycurrent_txtbox.setAttribute('type',"text");
mycurrent_txtbox.setAttribute('size',"25");
mycurrent_txtbox.setAttribute('value',"123");
mycurrent_cell.appendChild(mycurrent_txtbox);
mycurrent_row.appendChild(mycurrent_cell);
}

else{
mycurrent_cell = document.createElement("td");
mycurrent_txtbox = document.createElement("input");
mycurrent_txtbox.setAttribute('type',"text");
mycurrent_txtbox.setAttribute('size',"10");
mycurrent_cell.appendChild(mycurrent_txtbox);
mycurrent_row.appendChild(mycurrent_cell);}

}
}
mytablebody.appendChild(mycurrent_row);
}
mytable.appendChild(mytablebody);
mybody.appendChild(mytable);
mytable.setAttribute("border", "2");