Reputation: 112
In a project of mine hosted in server when I load one page gives me this error in
SCRIPT1005: Expected '('
File: users.asp, Line: 3, Column: 19
in the code I have this
<script language="javascript" type="text/javascript">
<!--
function datatable-users_onclick() {
}
// -->
</script>
but I can't figure where's missing the '(' like the error says...
EDITED: user.asp file
<!-- #include file="common/header.asp" -->
<!-- #include file="common/_db.asp" -->
<script language="javascript" type="text/javascript">
function datatable_users_onclick() {
}
</script>
<div class="row">
<div class="col-md-12">
<h2>Colaborador</h2>
<br/>
<table class="table dt-responsive" id="datatable-users" onclick="return datatable_users_onclick()">
<thead>
<tr>
<th>User-NT</th>
<th>Nome</th>
<th>Username</th>
<th>Acção</th>
</tr>
</thead>
</table>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="userAddModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog modal-sm" role="document">
<div class="modal-content">
<form method="post" action="user_save.asp" id="userAdd">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Novo Colaborador</h4>
</div>
<div class="modal-body">
<div class="form-group">
<p>Username:</p>
<input type="text" class="form-control input-sm" name="username" id="username" maxlength="50" required>
</div>
<div class="form-group">
<p>Password:</p>
<input type="text" class="form-control input-sm" name="password" id="password" maxlength="50" required>
</div>
<div class="form-group">
<p>Nome Completo:</p>
<input type="text" class="form-control input-sm" name="fullname" id="fullname" maxlength="50" required>
</div>
<div class="form-group">
<p>Departmento:</p>
<select class="form-control" name="department" id="department" required>
<% GetDepartments %>
</select>
</div>
<div class="form-group">
<p>Papel:</p>
<div class="radio">
<label><input type="radio" value="2" name="role" checked>Colaborador</label>
</div>
<div class="radio">
<label><input type="radio" value="1" name="role">Admin</label>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default btn-sm" data-dismiss="modal">Fechar</button>
<button type="submit" class="btn btn-primary btn-sm">Guardar</button>
</div>
</form>
</div>
</div>
</div>
<%
Sub GetDepartments
Set RS = Conn.Execute("SELECT * FROM Departments")
If Not RS.EOF Then
Do Until RS.EOF
departmentId = RS("id")
departmentName = RS("department")
Response.Write "<option value=" & departmentId & ">" & departmentName & "</option>"
RS.MoveNext
Loop
End If
RS.Close
End Sub
%>
<!-- #include file="common/footer.asp" -->
Upvotes: 0
Views: 2162
Reputation: 295
You cannot have a hyphen. It should be datatable_users_onclick()
instead of
datatable-users_onclick()
.
Upvotes: 0
Reputation: 16671
This is a classic case of not understanding the difference between Server-Side and Client-Side code.
The error you receive
SCRIPT1005: Expected '('
File: users.asp, Line: 3, Column: 19
is coming from the ASP Engine while the script is being executed by the Server and due to an error exits the script and sends an error response (HTTP 500 Internal Server Error
) to the Client (Internet Browser).
Depending on where your HTML is outputted in the ASP script it's likely that
<script language="javascript" type="text/javascript">
<!--
function datatable-users_onclick() {
}
// -->
</script>
is never outputted to the client (hence no error in the Client console).
All the answers about client-side JavaScript function name being incorrect are right but completely irrelevant as the error occurs before any response is sent to the Client.
The error will lie in one of the ASP code blocks <% %>
that equates to Line 3. It's likely you have a function or sub procedure call that has a missing opening bracket (
for example or a Response.Write()
statement that has gone awry.
Upvotes: 0
Reputation: 6992
You can start a variable/function with any letter, $, or _ character. As long as it doesn't start with a number, you can include numbers as well.
Start: [a-z], $, _
Contain: [a-z], [0-9], $, _
your are using "-" which is invalid use _ instead
<script language="javascript" type="text/javascript">
function datatable_users_onclick() {
}
</script>
Upvotes: 2