omdx omdx - 1 year ago 57
PHP Question

redirect page based select option (with dynamic value)

my selectbox:

<select name="JnsDaftar" id="JnsDaftar" required>
<option value="" disabled selected></option>
<option value="A">1 - A</option>
<option value="">2 -</option>
<option value="B">3 - B</option>
<option value="C">4 - C</option>
<option value="D">5 - D</option>
<label for="JnsDaftar">KARABO TANGKAL!</label>

N i want to redirect to if I select option 2. Other Value not redirect.

-- Edit --

I want to live redirect it to new page if I select option 2. Not via Post request. maybe javascript or Jquery. And the other option not redirect (the other option i want to save value by post request). thx

-- Edit --


Answer Source

I Solved with this code:

$( document ).ready(function() {
$('#JnsDaftar').on("change", function(e){

  if($(this).val() == ''){

        text: "Anda akan diarahkan pada laman PERBAIKAN BIODATA WNI!",
        type: "info",
        confirmButtonText: "OK"
        window.location.href = "i";

}); });

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download