0

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';

        }

    });

});
1
  • if($('#channel_code option:selected').val() == 'prop2'){ try this Commented Nov 14, 2016 at 6:29

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, However its still going to the old url on mobile mmm
that is a different problem that the current one then :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.