link_to submit form value 2

Hi to all,

I'd like to pass with a link to values inside some form. I've read in
other posts that it's possible if i include the forms inside a html
<div>...
So here it's my code of the view :

<div id="study">
<table>
        <tr><td><label for="study_titolo">Titolo di
studio</label></td></tr>
        <tr><td><label
for="study_istituto">Istituto</label></td><td><label
for="study_conseguito">Data di conseguimento</label></td><td><label
for="study_voto">Voto/giudizio</label></td></tr>
        <tr><td><%= text_field 'study', 'istituto'%></td><td><%=
date_select 'study', 'conseguito', {:include_blank =>
true}%></td><td><%= text_field 'study', 'voto'%></td></tr>
</table>
</div>

<%=link_to "Aggiungi", { :controller => "studies", :action=> "create",
:id_nominee => @nominee.id, :study => @study}, :submit => 'study', :html
=> { :method => :post} %>

where in submit value of Link_to i've specified the div id.
When i click on link_to no forms values are passed…
Can somebody help me???

Hi to all,

I'd like to pass with a link to values inside some form. I've read in
other posts that it's possible if i include the forms inside a html
<div>...

That sounds made up to me. Links (without javascript help) don't
submit forms. if you have to have a link that submits a form, by far
the easiest way is to have a link whose onclick is $
('some_form').submit() (link_to_function makes this easy).

Fred

Frederick Cheung wrote:

Hi to all,

I'd like to pass with a link to values inside some form. I've read in
other posts that it's possible if i include the forms inside a html
<div>...

That sounds made up to me. Links (without javascript help) don't
submit forms. if you have to have a link that submits a form, by far
the easiest way is to have a link whose onclick is $
('some_form').submit() (link_to_function makes this easy).

Fred

hi Fred,
this is the topic http://www.ruby-forum.com/topic/146247#new where i've
read the suggestion...
So i was searching the right syntax for doing that, i'll try to know
more about link_to_function, but i'd like to know if it's really
possible in the other way, cause i've found more than one person that
suggest that way...
Tanks for your reply

Andrea

Frederick Cheung wrote:

Hi to all,

I'd like to pass with a link to values inside some form. I've read
in
other posts that it's possible if i include the forms inside a html
<div>...

That sounds made up to me. Links (without javascript help) don't
submit forms. if you have to have a link that submits a form, by far
the easiest way is to have a link whose onclick is $
('some_form').submit() (link_to_function makes this easy).

Fred

hi Fred,
this is the topic http://www.ruby-forum.com/topic/146247#new where
i've
read the suggestion...

That's just wrong. Probably confused by the fact that link_to_remote
does take a :submit option (which should be the id of a form element)

Fred

Andrea Campagna wrote:

<%=link_to "Aggiungi", { :controller => "studies", :action=> "create",
:id_nominee => @nominee.id, :study => @study}, :submit => 'study', :html
=> { :method => :post} %>

where in submit value of Link_to i've specified the div id.
When i click on link_to no forms values are passed…
Can somebody help me???

I am doing the exact thing that you are asking about the only difference
is that I am using a link_to_remote, here is my code:

<%= link_to_remote('<span>Save</span>',
  {:submit => "car_prefs", :update => 'account_car_prefs',
   :complete => 'new Effect.Pulsate(\'account_car_prefs\');',
   :url => {:action => 'car_prefs', :id => @account.id}},
  :class => "squarebutton") %>

My car_prefs div encapsulates all the textfields and dropdowns and then
the :complete just updates another div - account_car_prefs - when the
action has completed. You might also try looking at the source to make
sure that the html is being generated properly, I say this because it
seems more often then not, for me, that I always get the { } put in the
wrong place when using additional options and you can also tell if you
are using them wrong because the html doesn't get formed right.

-S

Shandy Nantz wrote:

<%= link_to_remote('<span>Save</span>',
  {:submit => "car_prefs", :update => 'account_car_prefs',
   :complete => 'new Effect.Pulsate(\'account_car_prefs\');',
   :url => {:action => 'car_prefs', :id => @account.id}},
  :class => "squarebutton") %>

My car_prefs div encapsulates all the textfields and dropdowns and then
the :complete just updates another div - account_car_prefs - when the
action has completed. You might also try looking at the source to make
sure that the html is being generated properly, I say this because it
seems more often then not, for me, that I always get the { } put in the
wrong place when using additional options and you can also tell if you
are using them wrong because the html doesn't get formed right.

-S

Hi Shandy,

really thanks for your reply.... NOw it works!!!
I was really SAD for the first answer :smiley: now i'm better

Shandy Nantz wrote:

<%= link_to_remote('<span>Save</span>',
{:submit => "car_prefs", :update => 'account_car_prefs',
  :complete => 'new Effect.Pulsate(\'account_car_prefs\');',
  :url => {:action => 'car_prefs', :id => @account.id}},
:class => "squarebutton") %>

My car_prefs div encapsulates all the textfields and dropdowns and
then
the :complete just updates another div - account_car_prefs - when the
action has completed. You might also try looking at the source to
make
sure that the html is being generated properly, I say this because it
seems more often then not, for me, that I always get the { } put in
the
wrong place when using additional options and you can also tell if
you
are using them wrong because the html doesn't get formed right.

-S

Hi Shandy,

really thanks for your reply.... NOw it works!!!
I was really SAD for the first answer :smiley: now i'm better

Just so you're aware, the above does rely on javascript and the
prototype libraries - it won't work without javascript.

Fred