i would like to add buttons to the search block form that change the action actually triggered by "submit." my approach is to use the method here (http://drupal.org/node/154137) to add the buttons, and precede the form itself with a simple that modifies the action of the form when either of those buttons is clicked.

but the ID of the form, "search-block-form", seems to cause an error... when the page loads, it tells me that the following syntax has a badly formed left side:

document.search-block-form.action = "http://elsewhere";

so i figure i need to change that form ID. my brute force approach, however (change all instance of "search_block_form" in search.module to "sbForm" seems not to be correct.

has anyone else done anything like this?

Comments

datawench’s picture

i seem to do this alot.

anyway...

the brute force approach actually did wind up working, but figuring it out helped me track down my original error, which had to do with properly addressing the form id.

so now, i'm using this basic method: http://drupal.org/node/154137

but my search-block-template.php looks like this:

<script>
function setSearchTarget(t){
	document.getElementById('search-block-form').action = t;
}
</script>
<input type="text" maxlength="128" name="search_block_form_keys" id="edit-search_block_form_keys"  size="25" value="" title="Enter the terms you wish to search for." class="form-text" />
<input type="radio" name="starget" id="starget" value="local" checked onClick="javascript:setSearchTarget('/search/node');"/>Local
<input type="radio" name="starget" id="starget" value="elsewhere" onClick="javascript:setSearchTarget('http://search.sisterdomain.com);"/>Sister Domain
<input type="submit" name="op" value="Search"  />
<input type="hidden" name="form_id" id="edit-search-block-form" value="search_block_form" />
<input type="hidden" name="form_token" id="a-unique-id" value="<?php print drupal_get_token('search_block_form'); ?>" />
walker2238’s picture

I know this really late. But I was looking at doing something long the same lines. I'm using d6 but this should be also possible in d5... not sure though. If you wanted to change the form id, and in my case I did because edit-name is used more than once and was causing a problems with some jquery scripts I was using. You can do so by using hook_form_alter()

$form['name']['#id'] = 'edit-username';