Swap a form value using javascript

Hi all,

I want to swap a form value using javascript.

I can see taht this isn’t working…I don’t use javascript alot so I’m not too sure what I am doing.

thanks

<html> 
<head>
<title>AntiSpam</title>
<script language="JavaScript" type="text/javascript">
var antispam = 'false';
</script>
</head>
<body onLoad="main();" onclick="antispam = 'true'" onkeyup="antispam = 'true'" > 
<form method="GET" action="antispam.php">
<input type="hidden" name="antispam" id="antispam" value="false" />
<input type="submit">
</form>


<script language="JavaScript" type="text/javascript">
document.write(antispam);
</script>
<br>




</body>
</html>

How about you explain what it is you are actually trying to achieve? (I don’t mean, like the thread title - I mean the actual end goal; what functionality are you trying to get?)

If you’re trying to catch people’s mouse clicks and prevent right-click etc. then forget it - such techniques are so easy to get around. :wink:

Don’t know exactly what you want to do but I’d recommend downloading jQuery, it’ll make your life easier and your code more cross-browser compatible. To set a form value with jQuery, you would just do $(‘#antispam’).val(‘My Value!’);

it is for antispam, to prevent bot submission.

I’d just like to know how to change the value of a post variable using javascript.