Hi all. I have the standard search form . I have (via hook_form_alter) unset the $form['submit'] button and I have insert this
//unset($form['submit']); $form['search_block_form_keys']['#size'] = 18; $form['sumbit2'] = array( '#value' => '>>', '#prefix' => '<div class="submit"><a onclick="submitSearch();return false;" href="#">', '#suffix' => '</a></div>', );
drupal_add_js(" function submitSearch() { document.getElementById('search-block-form').submit(); return false; } ","inline"); break;
I have thinked that this worked (when click on the A TAG my "submitSearch()" function is call) but it si not true. The only way to make this works is to remove the // before unset() [first line of my code]
Why this ?
On Fri, 30 May 2008 01:32:17 +0200 Davide Michel 'ZioBudda' Morelli michel@ziobudda.net wrote:
Hi all. I have the standard search form . I have (via hook_form_alter) unset the $form['submit'] button and I have insert this
//unset($form['submit']); $form['search_block_form_keys']['#size'] = 18; $form['sumbit2'] = array( '#value' => '>>', '#prefix' => '<div class="submit"><aonclick="submitSearch();return false;" href="#">', '#suffix' => '</a></div>', );
drupal_add_js(" function submitSearch() {document.getElementById('search-block-form').submit(); return false; } ","inline"); break;
I have thinked that this worked (when click on the A TAG my "submitSearch()" function is call) but it si not true. The only way to make this works is to remove the // before unset() [first line of my code]
Why this ?
I think FAPI does some check on the existence of a '#type'=> 'submit'. Furthermore to get the onClick event you don't have to wrap an anchor around the button you'd just have to add attributes to the form element. Beware of the document.getElement... I'm not a js guru but it may not work on all browsers (the DOM is not the same in IE/ffox), you'd need a wrapper. I think all the JS goodies that comes with drupal should have one. Actually... if you dig into jQuery you may discover there is already something ready to do exactly what you'd like in a more drupalish way.
Ivan Sergio Borgonovo ha scritto:
I think FAPI does some check on the existence of a '#type'=> 'submit'. Furthermore to get the onClick event you don't have to wrap an anchor around the button you'd just have to add attributes to the form element.
an anchor around the button ??? I don't have an anchor around the button. I want to eliminate the button and leave only the "<a href....> >> </a>" (or imagine a GIF). I can delete it via unset but then the form does not works. So I can delete it via CSS (display:none), but I ak myself why this. I think that there is some type of check, too.
Beware of the document.getElement... I'm not a js guru but it may not work on all browsers (the DOM is not the same in IE/ffox), you'd need a wrapper. I think all the JS goodies that comes with drupal should have one.
The code is not tested in IE (for the moment is only a test).
Actually... if you dig into jQuery you may discover there is already something ready to do exactly what you'd like in a more drupalish way.
Do you know some exact url ?
M.
On Fri, 30 May 2008 14:27:32 +0200 Davide Michel 'ZioBudda' Morelli michel@ziobudda.net wrote:
Ivan Sergio Borgonovo ha scritto:
I think FAPI does some check on the existence of a '#type'=> 'submit'. Furthermore to get the onClick event you don't have to wrap an anchor around the button you'd just have to add attributes to the form element.
an anchor around the button ??? I don't have an anchor around the button. I want to eliminate the button and leave only the "<a href....> >> </a>" (or imagine a GIF). I can delete it via unset but then the form does not works. So I can delete it via CSS (display:none), but I ak myself why this. I think that there is some type of check, too.
This is easier obtained with something like:
<input id="search_submit" type="image" src="somewhere/search.gif" name="op" value="Search" />
At least in D5. op was deprecated. I don't know if it is still alive in D6.
Actually... if you dig into jQuery you may discover there is already something ready to do exactly what you'd like in a more drupalish way.
Do you know some exact url ?
I'm not a JS guru. Drupal uses ahah and JQuery libraries for JS. There are some books about JQuery, I don't know about ahah. Then there should be some docs on Drupal integration on drupal web site.
Ivan Sergio Borgonovo ha scritto:
This is easier obtained with something like:
<input id="search_submit" type="image" src="somewhere/search.gif" name="op" value="Search" />
I don't have an image. I have a A HREF TAG. I know HTML.
M.