0

The page source:

<html>
<head>
<title>Admin Search Results</title>

<script type="text/javascript">
function delete()
{     
    alert("abc");
}
</script>
</head>
<body>
<h1>Admin Search Results</h1>
<form id="modDel" action="modDel.pl" method="post" onsubmit="return delete()">
<table border="1">
<tr>
<th>User Name</th>
<th>Email</th>
<th>First Name</th>
<th>Last Name</th>
<th>Password</th>
<th>Blocked</th>
<th>Modify</th>
<th>Delete</th>
</tr>
<tr>
<input type="hidden" id="un_0" name="un_0" value="aa">
<td>aa</td>
<td>aa</td>
<td>aa</td>
<td>aa</td>
<td>aa</td>
<td>0</td>
<td><input type="submit" name="modify_0" value="Modify"></td>
<td><input type="checkbox" id="delete_0" name="delete_0" value="Yes"></td>
</tr>
<tr>
<input type="hidden" id="un_1" name="un_1" value="a">
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
<td>a</td>
<td>0</td>
<td><input type="submit" name="modify_1" value="Modify"></td>
<td><input type="checkbox" id="delete_1" name="delete_1" value="Yes"></td>
</tr>

</table>
<input type="hidden" id="count" name="count" value="1">
<input type="submit" id="delete" name="delete" value="Delete Selected Accounts" onclick="delete()">
<button type="button" onclick="delete()">Display Date</button>
</form>
</body>
</html>

It's generated by a Perl script from two templates (one for the table).

All I want is to get something to happen on some event. I've added onsubmit and onclick but neither work.

I'm sure I'm just missing something small but I can't see it. I'm using Chrome, BTW.

Edit: I can get it to work by adding the js code directly into the onclick/onsubmit quotes.

1 Answer 1

3

The problem here is that delete is a reserved word in JavaScript. Try a different function name. Also there is no need for the return in the onsubmit function, just invoke the function directly.

<script type="text/javascript">
function deleteFunc()
{     
    alert("abc");
}
</script>
</head>
<body>
<h1>Admin Search Results</h1>
<form id="modDel" action="modDel.pl" method="post" onsubmit="deleteFunc()">
Sign up to request clarification or add additional context in comments.

4 Comments

Wow. I new it would be something simple. Thanks a lot.
Also fix his inline event handlers o/
i inserted the extra returns because i saw them in an example somewhere while trying to troubleshoot my problem. I'll remove them now though.
ok, nvm. i did need the extra returns. They stop my form from submitting if i return false. I imagine there is a better way to this though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.