نحوه دسترسی به خونه های اول یک table
با سلام خدمت دوستان خوب برنامه نویس
من یک جدول دارم که به صورت اتوماتیک بهش text input اضافه میکنم.
حالا میخوام به مقدار خونه اول هر سطر که از نوغ text input هست دسترسی داشته باشم ، از دوستان خواهش میکنم کمکم کنن انقدر search کردم و به جواب دلخواه نرسیدم کلافه شدم.
:گریه::گریه:
نقل قول: نحوه دسترسی به خونه های اول یک table
سلام
کدهایی که برای اضافه کردن Input نوشتید رو قرار بدید .
نقل قول: نحوه دسترسی به خونه های اول یک table
var tbody = document.getElementById('tarrifTable').getElements ByTagName("tbody")[0];
var row = document.createElement("tr");
var td1 = document.createElement("td");
td1.appendChild(document.createElement("input"));
td1.firstChild.setAttribute("type", "text");
td1.firstChild.setAttribute("value", document.getElementById('txt_TarrifCode').value);
td1.firstChild.setAttribute("id", "CUpdate" + document.getElementById('txt_TarrifCode').value);
td1.firstChild.setAttribute('disabled', 'disabled');
var td2 = document.createElement("td");
td2.setAttribute('id', document.getElementById('txt_TarrifName').value);
td2.appendChild(document.createElement("input"));
td2.firstChild.setAttribute("type", "text");
td2.firstChild.setAttribute("value", document.getElementById('txt_TarrifName').value);
td2.firstChild.setAttribute("id", "NUpdate" + document.getElementById('txt_TarrifCode').value);
td2.firstChild.setAttribute('disabled', 'disabled');
var td3 = document.createElement("td");
td3.appendChild(document.createElement("input"));
td3.firstChild.setAttribute("type", "text");
td3.firstChild.setAttribute("value", document.getElementById('txt_TarrifusedStuffPrice' ).value);
td3.firstChild.setAttribute("id", "UUpdate" + document.getElementById('txt_TarrifCode').value);
td3.firstChild.setAttribute('disabled', 'disabled');
var td4 = document.createElement("td");
td4.appendChild(document.createElement("input"));
td4.firstChild.setAttribute("type", "text");
td4.firstChild.setAttribute("value", document.getElementById('txt_TarrifExecutionCost') .value);
td4.firstChild.setAttribute("id", "EUpdate" + document.getElementById('txt_TarrifCode').value);
td4.firstChild.setAttribute('disabled', 'disabled');
var td5 = document.createElement("td");
td5.appendChild(document.createElement("input"));
td5.firstChild.setAttribute("type", "text");
td5.firstChild.setAttribute("value", document.getElementById('txt_TarrifDutyCoefficient ForEC').value);
td5.firstChild.setAttribute("id", "DUpdate" + document.getElementById('txt_TarrifCode').value);
td5.firstChild.setAttribute('disabled', 'disabled');
var td6 = document.createElement("td");
var input = document.createElement('input');
input.type = "button";
input.value = "حذف";
input.id = "Delete" + document.getElementById('txt_TarrifCode').value;
input.setAttribute("onClick", "TarrifDeleteRow('" + input.id + "')");
td6.appendChild(input);
var td7 = document.createElement("td");
var inputEdit = document.createElement('input');
inputEdit.type = "button";
inputEdit.value = "ویرایش";
inputEdit.id = "Update" + document.getElementById('txt_TarrifCode').value;
inputEdit.setAttribute("onClick", "TarrifEditRow('" + inputEdit.id + "','C" + inputEdit.id + "','N" + inputEdit.id + "','U" + inputEdit.id + "','E" + inputEdit.id + "','D" + inputEdit.id + "')");
td7.appendChild(inputEdit);
row.appendChild(td1);
row.appendChild(td2);
row.appendChild(td3);
row.appendChild(td4);
row.appendChild(td5);
row.appendChild(td6);
row.appendChild(td7);
tbody.appendChild(row);
$('#tarrifTable tr:odd').css('background-color', '#073149');
$('#tarrifTable tr:even').css('background-color', '#3A99B9');
نقل قول: نحوه دسترسی به خونه های اول یک table
نمیدونم چرا این جواب نمیده
function TarrifDeleteRow(tarrifId) {
var table = $('#tarrifTable');
table.find('tr').each(function (index, row) {
var allCells = $(row).find('td:first input:first');
.
.
.
.
});
}
:عصبانی++::عصبانی++::عصبانی++:
نقل قول: نحوه دسترسی به خونه های اول یک table
درستش کردم
function TarrifDeleteRow(tarrifId) {
var table = $('#tarrifTable');
table.find('tr').each(function (index, row) {
var allCells = $(row).find('td:first').find('input:last');
if ($(allCells).val() == tarrifId) {
$(row).remove();
}
});