doushou5761 2017-03-18 15:50
浏览 279
已采纳

从第二种形式传递第二个参数?

I'm using laravel 5.4, my question is how can I pass a second parameter from a different form.

I know when I have multiple inputs in the same form I can pass multiple parameters

<form action="" method="get">
   <input type="text" name="country" placeholder="country">
   <input type="text" name="town" placeholder="town">
</form>

If I search here I would get something like website.com/?country=croatia&town=zagreb

but how can I get the same result but from two forms

<form action="" method="get">
   <input type="text" name="country" placeholder="country">
</form>

<form action="" method="get">
   <input type="text" name="town" placeholder="town">
</form>

I need to be able to search one form, and then the second if I want lets say I search for a country first and I get

website.com/?country=croatia

and now I want to search also for a town and I get

website.com/?country=croatia&town=zagreb

It should work the other way around!(If I search for a town first and the a country second. I know that this is a bad example)

  • 写回答

1条回答 默认 最新

  • dongliao6777 2017-03-18 18:48
    关注

    A bit complicated what you are trying to do. But there are some workarounds.

    Your first form

    <form action="" method="get">
        <input type="text" name="country" placeholder="country">
    </form>
    

    Your second form

    <form action="" method="get">
        <input type="hidden" name="country" value="{{ request('country') }}">
        <input type="text" name="town" placeholder="town">
    </form>
    

    When you submit the second form, it will actually recreate the URL by taking the values from the URL. At the end of the day, you have your second form "adding" parameters to the URL.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大