Conditon for button

hi everyone

I have two url_to action, like this

converter: ‘<%= url_for :controller => ‘/project/report’, :action
=> ‘converter’ %>’,

work_sheet_csv: ‘<%= url_for :controller => ‘/project/report’, :action
=> ‘work_sheet_csv’ %>’,

and I have a selection like

csv template_of_roster template_of_roster1 template_of_roster2 template_of_roster3

I have a button and I want to write condition for two url. when I select
csv and click button, want to run work_sheet_csv, when I select one of
the templates, want to run converter.

how can I write condition for it.
thanks for any help…

Use select tag like this

select_tag(‘id’, options_for_select([[foo],[bar]]),
:onchange=>remote_function(:url =>{:action => ‘yr_rails_method’},:with
=> “‘id=’+this.value”, :method=>:post),:style => “width:
220px;font-size: 90%;” )

in yr rails method u can check for the value("‘id=’+this.value") and
redirect it.

All the best

Simplify your public interface and just use one action. Since
converter handles most of the possibilities, I’d default to it and
allow it to delegate to work_sheet_csv if necessary.

def convert
work_sheet_csv and return if params[:tempates]==‘work_sheet_csv’
… current convert code …
end

private
def work_sheet_csv

end

If that feels uncomfortable, then use a new action and let it simply
delegate all the calls to either converter or work_sheet_csv as
necessary.

On Feb 20, 1:57 am, Ibrahim D. [email protected]

Ratnavel S. wrote:

Use select tag like this

select_tag(‘id’, options_for_select([[foo],[bar]]),
:onchange=>remote_function(:url =>{:action => ‘yr_rails_method’},:with
=> “‘id=’+this.value”, :method=>:post),:style => “width:
220px;font-size: 90%;” )

in yr rails method u can check for the value("‘id=’+this.value") and
redirect it.

All the best

thank you very much for your help.
I have a question to your suggestion. first I need to use the value of
option
because another method need it as well. another thing is that it s not
object of form. selection is not used in form. lastly there will be
button which should realize the selection and run the suitable url. as
you see in selection there are some template names and work_sheet_csv. I
will use another selection if I manage to get parameter from selection.

btw thank you very much for your help Ratnavel S…

Ibrahim D. :

I advice you to paste your both of your controllers and index.rhtml
using http://pastie.caboo.se/ and paste the links here, so they can
understand the main your problem. I believe they can solve the problem
if they can read your entire script, because your problem is how to call
first the url of csv from your javascript function that you wrote in
index.rhtml. I am not good in JS.

Reinhart Ariando

Visit Indonesia 2008 wrote:

Ibrahim D. :

I advice you to paste your both of your controllers and index.rhtml
using http://pastie.caboo.se/ and paste the links here, so they can
understand the main your problem. I believe they can solve the problem
if they can read your entire script, because your problem is how to call
first the url of csv from your javascript function that you wrote in
index.rhtml. I am not good in JS.

Reinhart Ariando

my problem is that get parameter from selection which is not in form
object.

thank you very much for your help Reinhart Ariando. you spent your time
for me.