function OnSuccess(xml) {
document.getElementById("people").innerHTML = "<tr><td>Employee ID</td><td>First Name</td><td >Last Name</td></tr>";
$(xml).find('Table').each(function() {
var id = $(this).find('EmployeeID').text();
var fn = $(this).find('FirstName').text();
var ln = $(this).find('LastName').text();
//Create button
var btn = document.createElement("input");
//Set the attributes
btn.setAttribute("onclick", "ServiceCall3(id)");
btn.setAttribute("type", "button");
btn.setAttribute("value", "Info");
btn.setAttribute("name", id);
$('#people').append('<tr><td>' + id + '</td><td>' + fn + '</td><td>' + ln + '</td><td> '+ btn + '</td></tr>')
}
)};
안녕하세요, 이것은 xml 파일에서 테이블을 만드는 제 기능입니다. 필요한 것은 xml의 read 매개 변수와 동일한 id의 버튼을 추가하는 것입니다. 각 행의 끝 부분입니다. 버튼 대신 얻는 것은 [object HTMLInputElement]입니다. 도와주세요.자바 스크립트를 사용하여 테이블에 버튼 추가하기
위대하고 빠른 응답. ServiceCall3에 id 값을 어떻게 전달할 수 있습니까? ServiceCall3에서 사용 하시겠습니까?
function serviceCall3(id) {
$.ajax({
type: "POST",
url: "../TestWebService.asmx/GetAll",
data: "{'data' :" + id + "}",
contentType: "application/json; charset=utf-8",
dataType: "xml",
success: OnSuccess3,
error: OnError
});
}
완료,하지만 내 출력은 여전히 내가 내 대답에 언급 된 어떤 시도 같은 –
입니까? 당신이 console.log 나'(Create button) '앞의 id (id)를 바꾼다면 –
얘들 아, 어떻게 ServiceCall3 함수에 id 매개 변수를 전달할 수 있겠 니? –