[英]PHP dropdown if value is selected
I currently have a block of jQuery that I have included this seems to work fine on the comps I have tested OSX, XP
however on mobile devices and another computers I have had people to test its still going to the old URL however I do suspect it could be a cache issue but is there a way to develop a PHP fall back? 我目前有一个jQuery块,我在其中包含了这个功能,似乎在我测试过OSX, XP
的压缩程序上工作正常OSX, XP
但是在移动设备和另一台计算机上,我已经有人对其进行过测试,但仍然使用旧网址,但是我怀疑可能是缓存问题,但是有没有办法开发PHP回退?
What I would like to do if the prop2
value is selected I would like to change the form action url almost onclick like the jQuery does. 如果选择了prop2
值,我想做什么我prop2
jQuery一样在onclick上更改表单动作url。
HTML: HTML:
<form action='bookingurl' method='get'>
<label for='channel_code' class="caption">Select property </label>
<select id='channel_code' name='id'>
<option value='prop1'>Prop 1</option>
<option value='prop2'>Prop 2</option>
</select>
</form>
jQuery: jQuery的:
jQuery(document).ready(function(){
jQuery('#channel_code').change(function(){
if(jQuery('#channel_code').val() == 'prop2'){
window.location.href = 'https://hotels.cloudbeds.com/reservation/url';
}
});
});
$(document).ready(function() { $('#channel_code').change(function() { if ($('#channel_code option:selected').val() == 'prop2') { alert("go to") //window.location.href = 'https://hotels.cloudbeds.com/reservation/url'; } }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <form action='bookingurl' method='get'> <label for='channel_code' class="caption">Select property</label> <select id='channel_code' name='id'> <option value='prop1'>Prop 1</option> <option value='prop2'>Prop 2</option> </select> </form>
Specify the selector as: 将选择器指定为:
$('#channel_code option:selected').val()
//meaning option selected value $('#channel_code option:selected').val()
//表示选择的选项值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.