账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    rails 使用 coffee 实现本页动态填写数据
    • 见心书画许老师187533751612017-11-23 00:00
    49
    0

    在rails 项目中
    有2个表

    create_table "cities", force: :cascade do |t|
        t.string   "name"
        t.integer  "province_id"
        t.datetime "created_at",  null: false
        t.datetime "updated_at",  null: false
        t.index ["province_id"], name: "index_cities_on_province_id"
      end
       create_table "provinces", force: :cascade do |t|
        t.string   "name"
        t.datetime "created_at", null: false
        t.datetime "updated_at", null: false
      end

    在cities/index.html中想实现
    前一个选择框可以选择某个省,第二个选择框自动提供所选省份的地级市(县)

    <%=
    collection_select(:city, :province_id, Province.all, :id, :name_with_initial, { prompt: true })
    %>
    <%=select_tag "city", option_groups_from_collection_for_select(@province, :cities, :name, :id, :name, 30)%>

    要怎么做

    1
    打赏
    收藏
    点击回答
        全部回答
    • 0
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部