开发者

Go to new URL when select_tag changes?

This ought to be very simple in Rails, but I'm still learning...

My code

Sort by <%= select_tag :sort, options, :onchange => "google.com" %>

should redirect to a page (google is just being used as a place开发者_如何学Cholder) when the criterion for sorting is changed.

In case it matters, it'll just be going to the same page, but with ?sort=sort type appended.

Thanks!


How about calling a js function through the onchange attribute?

Sort by <%= select_tag :sort, options, :onchange=>'myFunc(this.value)' %>

The js might be something like:

function myFunc(value) {
  window.location = "http://www.mydomain.com/myapp/mycontroller/myaction?sort="+value
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜