【问题标题】:Create drop-down menu using link_to that redirects to page when clicked?使用 link_to 创建下拉菜单,单击时重定向到页面?
【发布时间】:2023-03-22 03:45:01
【问题描述】:
<h2>Where are you from?</h2>
    <form>
        <select name="URL" onchange="window.location.href= this.form.URL.options[this.form.URL.selectedIndex].value">
        <option value="#">Connecticut</option>
        <option value="#">Michigan</option>
        </select>
    </form>

我想将存根的值链接到 pages_connecticut_path 和 pages_michigan_path

【问题讨论】:

    标签: html ruby-on-rails ruby hyperlink


    【解决方案1】:

    这样解决:

    <option><%= link_to 'Connecticut', pages_connecticut_path %></option>
    <option> <%= link_to 'Michigan', pages_michigan_path %></option>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-13
      • 2023-03-05
      • 2013-11-09
      • 1970-01-01
      相关资源
      最近更新 更多