如何选择选项时如何重定向页面,laravel
选择选项之一时,我需要重定向页面。
<select required name="subject" id="konu" class="form-control">
<option value="" disabled>Choose Subject</option>
<option value="Ask a question">Ask a question</option>
<option value="Leave a comment">Leave a comment</option>
<option value="Where to buy">Where to buy</option>
<option value="Product Complaint">Product Complaint</option>
<option value="Other">Other</option>
<option {{ request('subject') == 'Request SDS' ? 'selected' : '' }} value="Request SDS">Request SDS</option>
<option value="Distributor">Request Distributorship</option>
</select>
I need to redirect page when one of the option is selected.
<select required name="subject" id="konu" class="form-control">
<option value="" disabled>Choose Subject</option>
<option value="Ask a question">Ask a question</option>
<option value="Leave a comment">Leave a comment</option>
<option value="Where to buy">Where to buy</option>
<option value="Product Complaint">Product Complaint</option>
<option value="Other">Other</option>
<option {{ request('subject') == 'Request SDS' ? 'selected' : '' }} value="Request SDS">Request SDS</option>
<option value="Distributor">Request Distributorship</option>
</select>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我曾经也需要这个,发现您的问题已经得到回答。
如果您可以使用Inline JavaScript,请查看以下答案:
https://stackoverflow.com/a/7562129/10440010
同样的问题:
https://stackoverflow.com/a/7562201/10440010
我希望这会有所帮助!
更新:
使其适用于特定选项的简便方法是使Onchange事件检查点击选项的值是否等于某物。在下面的摘要中,我使其适用于以
https
开头的所有链接。HTML:
JavaScript:
希望这可以帮助您解决问题。如果没有,请发表评论,我很高兴提供帮助!
I once needed this too and found that your question has already been answered.
If you're fine with using inline JavaScript, check out this answer:
https://stackoverflow.com/a/7562129/10440010
If you prefer staying off of inline, check out this answer under the same question:
https://stackoverflow.com/a/7562201/10440010
I hope this helps!
Update:
An easy way of making it work for specific options, is to make the onChange event check whether the value of the clicked option equal to something. In the snippet below, I make it work for all links starting with
HTTPS
.HTML:
JavaScript:
Hopefully this helps you enough to solve your problem. If not, leave a comment and I am glad to help!
我先前有一个代码。
在这里选择它是脚本。
I have a code previously woked.Here is select
Here it is script.
对于第二个答案,HTML中使用的值与您在JavaScript代码中检查的值不同。
在您的html中,它是
distributor
,在您的JavaScript代码中,它是Distributor
。介意首都D。For the second answer, the value used in your HTML differs from the value you're checking against in the JavaScript code.
In your HTML, it's
Distributor
and in your JavaScript code it'sdistributor
. Mind the capital D.问题处于您的状况。您的价值是分销商,您使用分销商。 JS是案例感觉的,因此您不会重定向。代码应该看起来像
the problem is on your condition. Your value is Distributor and u using distributor. Js is case sensetive so you not getting any redirection. the code should look like