I would really like to know how i can submit a form without having to
have the standard submit_tag button on my form. i just want to say:
link_to “Save”, :action (((submit_form)))
Thanks.
I would really like to know how i can submit a form without having to
have the standard submit_tag button on my form. i just want to say:
link_to “Save”, :action (((submit_form)))
Thanks.
What’s the motivation behind this? do you just want to have a link to
click on instead of a button?
I don’t know of any ‘HTML built in’ solution for this but here is one
that uses javascript
In general using a link to sumbit a form (using GET instead of a POST)
is a dangerous thing to do, especially if this form will change contents
in your database. this is due to web crawlers that may crawl your
website and click on links - and therefore your db contents may change
behind the scenes. using POST is always the better way.
but I may have misunderstood your intention.
anyway, HTH.
Alon wrote:
What’s the motivation behind this? do you just want to have a link to
click on instead of a button?I don’t know of any ‘HTML built in’ solution for this but here is one
that uses javascriptHow to Make a Text Link Submit A Form Just Like a Submit Button (thesitewizard.com)
In general using a link to sumbit a form (using GET instead of a POST)
is a dangerous thing to do, especially if this form will change contents
in your database. this is due to web crawlers that may crawl your
website and click on links - and therefore your db contents may change
behind the scenes. using POST is always the better way.but I may have misunderstood your intention.
anyway, HTH.
Hi, thanks for your comments
I basically don’t want to have to use the ugly grey button that comes
with the submit_tag. Instead i want to have a button on my ‘side menu’
that when clicked on will submit the form. I therefore just want to be
able to use a link_to_function statement or something, where i am able
to click on a piece of text and the form will be submitted. is this
possible?
James S. wrote:
Alon wrote:
What’s the motivation behind this? do you just want to have a link to
click on instead of a button?I don’t know of any ‘HTML built in’ solution for this but here is one
that uses javascriptHow to Make a Text Link Submit A Form Just Like a Submit Button (thesitewizard.com)
In general using a link to sumbit a form (using GET instead of a POST)
is a dangerous thing to do, especially if this form will change contents
in your database. this is due to web crawlers that may crawl your
website and click on links - and therefore your db contents may change
behind the scenes. using POST is always the better way.but I may have misunderstood your intention.
anyway, HTH.
Hi, thanks for your comments
I basically don’t want to have to use the ugly grey button that comes
with the submit_tag. Instead i want to have a button on my ‘side menu’
that when clicked on will submit the form. I therefore just want to be
able to use a link_to_function statement or something, where i am able
to click on a piece of text and the form will be submitted. is this
possible?
I feel your pain, but I’m not sure how to cleanly tell link_to to get
all data from the form. The way previously suggested will work, and let
me explain further.
To submit a form from a link, make a form with a name (note: this can
also be a start_form_tag, just make html_options { :name => “myname” }:
and the link you want to submit:
Now, I haven’t tried this myself, but let me know if you hit a snag and
I’ll look into it. Also, I know this isn’t a pure rails solution, so if
someone knows of one please let us know.
~Jimmy
Thanks very much for your help.
I did find the rails way to do it in the end, which was as follows:
Naming the form:
<%= start_form_tag({ :action => ‘update’, :id => @input }, {:name =>
‘myform’}) %>
Assigning submission to a button:
<% @button3 = link_to_function “Save”, “myform.submit()” %>
Thanks again, your comments were very helpful.
James S. wrote:
I basically don’t want to have to use the ugly grey button that comes
with the submit_tag.
You don’t have to. That’s what CSS is for.
See: http://tom.me.uk/scripting/submit.html
<%= link_to_remote ‘Submit’, { :url => { :action => ‘create’ }, :with =>
"
Form.serialize($(‘form_id’))" }, { :class => “style_class” } -%>
Vish
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs