Forum: Ruby on Rails Form submit to look, feel, act like a link

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jake J. (Guest)
on 2007-02-21 03:29
Hey folks--

I'd like to create what looks like a link on a page.  But the link will
actually submit a form to another website to perform a search.

I'm currently doing something like:
  form_tag("http://www.othersite.com", :name => "link_form") +
  hidden_field_tag("one_param", "value1") +
  hidden_field_tag("two_param", "search text") +
  end_form_tag() +
  link_to_function("Search text", "document.link_form.submit();")

This works just fine on Firefox/Windows when I click with the left mouse
button.

However, I often click with the middle mouse button to open the page up
in another tab.  When I do that with this type of link, it just opens a
copy of the current page in the new tab -- i.e., it doesn't submit the
form.

This appears to be a common problem (after googling a bit), but I was
wondering if there's a better Javascript/RoR way to manage a solution.

Any suggestions?
This topic is locked and can not be replied to.