Beutelevision

by Thomas Beutel

Category: javascript

Detecting a click in a checkbox with jQuery

A simple script to detect when a checkbox is clicked. What you do with once you’ve detected the click is up to you.
<html>
<head>
<script src=”http://www.google.com/jsapi”></script>
<script>
google.load(”jquery”, “1.3.2″);
google.setOnLoadCallback(function() {
$(’#agree’).click( function() {
if($(this).attr(’checked’)){
alert(’checked’);
}
else{
[...]

Redirect from within a Wordpress admin page

I was trying to perform a redirect to generate a CSV file from within a Wordpress admin page using the wp_redirect( ) function, but the problem was that I would always get the dreaded “Cannot modify header information – headers already sent” message. This is because admin plugins are simply hooks that are performed within [...]

Result of expression ‘document.forms[0].submit’ [[object HTMLInputElement]] is not a function.

I was trying to add a small delay into my form submission like so:
<form … onsubmit=”setTimeout(’document.forms[0].submit()’,2000);return false;”>
but everytime I tried it, I got the following error:
Result of expression ‘document.forms[0].submit’ [[object HTMLInputElement]] is not a function.
This one had me stumped, until I realized what it was telling me… that my submit button was named “submit”.
<input type=”submit” [...]