I'd like to have a custom field interface show up only when a certain template is assigned to a particular WordPress page.
The script itself, which requires jQuery, simply hides or shows a metabox based on the selected value in the page template dropdown list. In this example, I'm only showing the metabox for post thumbnails in case the default page template is selected:
And, just for fun, here's a shorter, less verbose, version of the same script:
Rather than rendering the metabox only to hide it with jQuery you can use this. The only difference being that the hiding/showing of the metabox requires selecting 'Update' after changing the drop-down field.
Just update lines 6 and 7 as desired.