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

<select name="templates">     <option value="work_sheet_csv">csv</option>     <option value="template_of_roster">template_of_roster</option>     <option value="template_of_roster1">template_of_roster1</option>     <option value="template_of_roster2">template_of_roster2</option>     <option value="template_of_roster3">template_of_roster3</option>   </select>

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.

Ratnavel Sundaramurthi 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 Sundaramurthi...

Ibrahim Dogru :

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 Dogru :

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.