Forum Moderators: open
Here is a function that I call when I need to ban a user. The variable 'ban' gets the ban period and then I go to 'ban_ip.php' to update my database.
But it doesn't work! Nothing happens. I do not get to 'ban_ip.php'. If I add an alert message after 'document.message.action="ban_ip.php";' it is executed. My form is named 'message' and I did write within the form tags '<input name="ban" type="hidden"'. The console does not show an error.
I am out of ideas. Can you please help me?
Many thanks!
Roberto
<html><head><title>TEST</title>
<script>
function banned()
{
var ban_days = prompt("How long should the ban last? (from 1 to 365 days)", "3");
if (!ban_days ¦¦ ban_days <= 0 ¦¦ ban_days > 365)
return false;
document.message.ban.value = ban_days;
document.message.action="ban_ip.php";
return true;
}
</script>
</head>
<body>
<form name="message">
<input name="ban" type="text" value="" />
<input type="button" value="banned( )" onclick="banned()"><br>
<input type="submit">
</form></body>
</html>
..?
Unfortunately your suggestion doesn't work either: I never reach 'ban_ip.php'.
Yet, I found something interesting.
I actually use an image to trigger the function 'banned()':
print"<a href='' onClick=banned()> <img src='....../ban.gif' width=18 height=19 border=0 title='click here to ban this ip address'></a>"
But when I replace it with a traditional submit button it does work:
print"<input type='submit' value='' onClick='banned()'>";
Can you figure out why? I have not yet...
Roberto