简体   繁体   中英

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?

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.

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(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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM