jQuery - passing selected parameter value as URL

0 votes
774 views
added Mar 19, 2019 in jQuery by LC Marshal Captain (25,790 points)
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
var lcDomain = "https://lazacode.org/";
var value = "";
$(document).ready(function(){
    $("select").change(function(){
        // alert($(this).val());
        value = $(this).val();
        window.location.href = lcDomain+'&state='+value;
    });
});
</script>
</head>
<body>


Select State:
<select name="state"> 
  <option value ="">Choose</option>
  <option value="Kuala%20Lumpur">Kuala Lumpur</option> 
  <option value="Selangor">Selangor</option> 
</select>


</body>
</html>

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...