<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" type="text/css" href="/Users/skhare/myFirstStyleSheet.css">
<script src="http://code.jquery.com/jquery-1.7.1.min.js"> </script>
<script>
function myFunction(a){
window.alert("hi " + a);
$.getJSON('/Users/skhare/tableList.json', function(tableList) {
var output="<table id=tableStyle>";
output+="<tr>" + "<th>" + "Table Names" + "</th>" + "</tr>";
for (var i in tableList.t)
{
output+="<tr>" + "<td>" + "<a href=/Users/skhare/tableDescription.html>" + tableList.t[i].name + "</a>" + "</td>" + "</tr>";
}
output+="</table>";
document.getElementById("placeholder1").innerHTML=output;
});
}
</script>
<script>
$.getJSON('/Users/skhare/reportSuiteList.json', function(reportSuiteList) {
var output="<table id=tableStyle>";
output+="<tr>" + "<th>" + "id" + "</th>" + "<th>" + "name" + "</th>" + "<th>" + "stage" + "</th>" + "<th>" + "DWH" + "</th>" + "</tr>";
for (var i in reportSuiteList.suites)
{
output+="<tr>" + "<td>" + reportSuiteList.suites[i].REPORTSUITE_ID + "</td>" + "<td>" +
"<button class=\"report-suites\" id =\""+ reportSuiteList.suites[i].REPORTSUITE_NAME+ "\" onclick= \"myFunction(\'" + reportSuiteList.suites[i].REPORTSUITE_NAME + "\')\">"+reportSuiteList.suites[i].REPORTSUITE_NAME + "</button>" +
"</td>" + "<td>" + reportSuiteList.suites[i].STAGING_DATABASE + "</td>" + "<td>" + reportSuiteList.suites[i].DWH_DATABASE + "</td>" + "</tr>";
}
output+="</table>";
document.getElementById("placeholder").innerHTML=output;
});
</script>
</head>
<body>
<div id="placeholder"></div>
<br><br><br><br><br>
<div id="placeholder1"></div>
</body>
</html>
버튼을 클릭하여 함수를 호출하고 다른 정보를 표시하는 다른 스크립트를 렌더링하고 싶습니다. 위와 같은 두 스크립트를 병합 할 수 있습니까? 아니면 방법을 모르는 함수에 대해 외부 jquery 스크립트를 호출해야합니까?
코드를 실행하면 경고 메시지 만 표시됩니다.
다음과 같이 전달할 수 있습니다.
"myFunction('" + reportSuiteList.suites[i].REPORTSUITE_NAME + "')"
//----------^----insert a quote here.--------------------------^
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다