You are here: Forums Ask a Rails expert Submit in Layouts...
Posted in Forums : Ask a Rails expert
Authority 12
Posting Rating 0
Sign in to rate this post
|
Hi, I’m a newbie, I have a layout, with some buttons at the top of the layout, the form is then rendered within the layout. I would like the submit and cancel buttons within the layout and not the form. The buttons call a function submitbutton(buttonpressed), the problem is I don’t know how to change MyForm function submitform(buttonpressed){
if (pressbutton) {
document.MyForm.task.value=buttonpressed;
}
if (typeof document.MyForm.onsubmit == “function”) {
document.MyForm.onsubmit();
}
document.MyForm.submit(); Any help appreciated. |
Authority 0
Posting Rating 0
Sign in to rate this post
|
Well, you could change the function to something like this, of course modifying it to fit your situation, and add in the individual id’s of the forms: JS:
function submitForm(formid) {
document.getElementById(formid).submit();
}
HTML <form id="blah"> |
Authority 37
Posting Rating 94
Sign in to rate this post
|
If you have included the prototype javascript library, you can also have your buttons call: onclick=”$(‘my-form-id’).submit()”’ Which is basically a shorthand for the same idea that Charles mentioned. Make sure you put an “id” attribute on your form for this to work. |
Ask a Rails expert : Couldn't find Product without an ID
Ask a Rails expert : HTML to XML ---> get title & description
Ask a Rails expert : Accessing controller actions from scripted page?
Ask a Rails expert : seledted option for select_tag
Ask a Rails expert : Merging fields from two tables into one, including duplicates
Ask a Rails expert : saving has_many :through
Ask a Rails expert : Use Rails to develop sites for both Designer and Programmer
Ask a Rails expert : Rails+RS232
Ask a Rails expert : Is this a good way to add Admin section
Ask a Rails expert : RSS feed maker in rails 2.1