I can't really say what went wrong with the previous code you tried,
but here is how i would do it:

<%= text_field :contact ,:name,:class=>'roundRect',:id=>'name' %>
<%=link_to_remote('Go',
            :url =>{:controller => 'main', :action=> 'search'},
            :with => "'contact[name]=' + $('contact_name').value")%>

@bill walton: Can you use the :submit parameter of link_to_remote even
without wrapping the inputs in form tag? The documentation seems to
suggest so, but i've never tried ....

On Mar 9, 7:28 am, Jeba Momin <[email protected]>
wrote:
> Rakoth wrote:
> > Hello, you may add javascript to onclick event of your link.
>
> > <a href ="/main/search" onclick="return addParam(this);">GO</a>
>
> Hi
> Thank for helping.
> I tried this..but the problem I'm facing is that,the first time I click
> the link is as:http://localhost:3000/main/search
> On the second click the link is 
> as:http://localhost:3000/main/search?query=<text_field_value>
> On the thirdclick the link is 
> as:http://localhost:3000/main/search?query=<text_field_value>?query=<text_field_value>
> and so on....
> Can u please suggest how do I solve this???
> I'm not well versed with javascripts....
> Thank you again....
>
> bill walton wrote:
> > <%= link_to_remote 'Click me', :url => (:controller => 'main', :action
> > => 'search}, :submit => 'field_to_submit', :method => :post %>
>
> > When the link is clicked, the value you're looking for will be passed to
> > the controller via a POST and can be accessed using
> > params[:contact][:name]
>
> Thank you for your help..
> But it didn't work for me....   :(
> My code looks as:
> <div id='srchname'>
>   <%= text_field :contact ,:name,:class=>'roundRect',:id=>'name' %>
> </div>
> <%=link_to_remote('Go', :url =>{:controller => 'main', :action=>
> 'search'},:submit => 'srchname',:method =>'post')%>
>
> But it doesn't even go to the main/search method...
> Where am I going wrong???
> Thank You.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to