Witam.
W jaki sposób prawidłowo wywołać funkcję umieszczoną w osobnym pliku .js
?
Poniższy kod po naciśnięciu na przycisk Test 02
wyświetla w prawidłowy sposób okno, jednak po naciśnięciu na przycisk Test 01
nie następuje żadna reakcja.
Sortowanie tabeli działa bez problemów, więc plik table.js
jest prawidłowo wczytany.
table.js
$(function(){
$('#keywords').tablesorter();
});
function test_01() {
prompt("Test 01", "True");
}
table.php
<?php
include 'tableFunctions.php';
include 'loginFunctions.php';
if (!IsLogged())
{
header('Location: ../login.html');
die();
}
else
{
?>
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Table</title>
<link rel="stylesheet" href="../css/table.css">
</head>
<body>
<div id="wrapper">
<h1>Events</h1>
<?php
if (true)
{
$tableName = "Events";
$values = GetDataFromTable($tableName, array());
$columnNames = GetColumnNamesFromTable($tableName);
DrawTable($columnNames, $values);
}
?>
</div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script type="text/javascript" src="../js/resources/jquery.tablesorter.min.js"></script>
<script src="../js/table.js"></script>
<SCRIPT language="javascript">
function test_02()
{
prompt("Test 02", "True");
}
</SCRIPT>
<INPUT type="button" value="Test 01" onclick="test_01()" />
<INPUT type="button" value="Test 02" onclick="test_02()" />
</body>
<?php
}
?>