I am trying to submit a form with a text link (namely the search form) and it doesn't seem to be working. Everything with the form works fine, but if I change the submit button to something like:

  $form['submit'] = array(
  	'#value' => '<a href="javascript:void(0);" onclick="document.getElementById(\'global-search-form\').submit();">Submit</a>',
  );

it doesn't work. It submits the form fine and takes you to the search page, but the search is left blank.

If you would like you can test it on the site: http://www.gunslot.com. It is located in the top middle.

Thanks,
Quinton

Comments

pobster’s picture

Why not simply pass the search query into the URL like; http://www.gunslot.com/search/node/testing

Pobster

--------------------------------------------
http://www.justgiving.com/paulmaddern
--------------------------------------------

slayerment’s picture

I suppose that would work for this case, however, I also plan on doing this same type of thing for a number of other forms on my site such as the login which don't have parameters to be passed via the URI. I will go that route for now if there isn't a better way though :).

Thanks,
Quinton

slayerment’s picture

*bump*

Anymore ideas?

JerryH’s picture

Did you ever get any where with this ?

pianory’s picture

This is an old thread, but below is the way I worked it out in case it helps anyone.

<script type='text/javascript'>
Drupal.behaviors.mycustomformlink = function (context) {
  var $form = $('#my_form');
  // id "my_submit" is the submit button
  $('#my_submit').hide().after("<span id='my_data_link'><a href='#'>SUBMIT FORM</a></span><br />");
  $('#my_data_link').click(function() { $('#my_data_submit').click(); });
};
</script>
jack-pl’s picture

This goal can be achieved with the javascript attached to the form. A working example here.