<!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>
我想单击按钮的onclick来调用该函数并呈现另一个显示其他信息的脚本。我可以像上面那样合并这两个脚本吗?我是否需要为该函数调用外部jquery脚本,而我不知道该怎么做?
我运行的代码只是给我警报消息,没有其他
您可以像这样传递它:
"myFunction('" + reportSuiteList.suites[i].REPORTSUITE_NAME + "')"
//----------^----insert a quote here.--------------------------^
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句