Forum Moderators: open

Message Too Old, No Replies

Problem with 'document.XXX.action'

         

cameraguy

12:38 am on Mar 17, 2005 (gmt 0)

10+ Year Member



function banned()
{
var ban_days = prompt("How long should the ban last? (from 1 to 365 days)", "3");
if (ban_days == null) return false;
if (ban_days!= "" && Math.ceil(ban_days) > 0 && Math.ceil(ban_days) <= 365)
{
document.message.ban.value = ban_days;
document.message.action="ban_ip.php";
}

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

Bernard Marx

1:15 am on Mar 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<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>

..?

cameraguy

2:42 pm on Mar 17, 2005 (gmt 0)

10+ Year Member



Thank you!

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