[wp-hackers] Form in metabox, like Custom Fields

Peter peter at avirtualhome.com
Thu Sep 4 13:32:06 GMT 2008

I would like to create a metabox in the admin post and page section
with a "form" inside.

What I have right now is the following javascript:
jQuery(document).ready(function() {
		jQuery('#mysubmitbutton').click( metabox_mysubmit );

function metabox_mysubmit() {
	var values= new Array;
	values[0] = jQuery('tab-id').attr('value');
	if (values[0]) {
	return false;
function metabox_submit(this_action, this_output, this_values){
		 action: 'my_metabox',
		'cookie': encodeURIComponent(document.cookie),
		'mb_action': this_action,
		function(data, textStatus) {

Together with the PHP and HTML code this works, except for when you
press enter, I need to add jQuery('#myinput').keydown(metabox_myinput);
and check for key 13 in the metabox_myinput function. I know how to do
this, just haven't got to it.

In the end this solution will work, but I have been looking at the
Custom Fields metabox and have been wondering how that one works. I
would love to write my piece of code the same way this one is written
but I can't seem to figure it out.
Is there documentation on how this is done? Could somebody direct me
how to do this or maybe it's not possible at all.
I think it has to do with the class assigned to the submit button, but
my javascript knowledge isn't completely up to par to figure it out
myself without some direction.

Thanks in advance.

Peter van der Does

GPG key: E77E8E98
Blog: http://blog.avirtualhome.com
Forums: http://forums.avirtualhome.com
Jabber ID: pvanderdoes at gmail.com

GetDeb Package Builder
http://www.getdeb.net - Software you want for Ubuntu

More information about the wp-hackers mailing list