Javascript

Embedding the Drupal 7 search form in another site with jQuery

A section of my current project will be hosted by an external server/service. I hand them a HTML file, and they build their content within it. One problem is that the header search form must still work. For security reasons, Drupal won't accept a Form Post without the correct Form ID, so we need Drupal to generate the form.

Clear a form field on click with JS & Behaviors in Drupal 7

A common web design feature is to move the label for a form field into the field value, then clear the field once it gains focus. There are many ways to implement this functionality, but this is the Drupal 7 theming method.

These steps assume your theme contains no custom Javascript. They describe how to add the word Search to the regular Drupal search block text field.

  1. Open your template.php file.
  2. We will use hook_form_alter() to change the value of the search field:
Subscribe to Javascript