Question: Hello this is my current code:

```
<select id="link_course">
<option value="">Select Course</option>
<option value="ALL">ALL</option>
<option value="BSIT" selected>BSIT</option>
<option value="BSA">BSA</option>
<option value="BSBA">BSBA</option>
<option value="BSHRTM">BSHRTM</option>
</select>

<script>
    $("#link_course").change(function()
          {
              document.location.href = "home.php?course=" + $(this).val();

        });
</script>

```

If you click any of those options, for example BSBA, it will go to home.php?course=BSBA, and also you can see that the `selected` attribute is on the option BSIT. What I wanted to do is whenever I click another link, for example BSHRTM, the `selected` attribute will go to BSHRTM like it would be `<option value="BSHRTM" selected>BSHRTM</option>`. Any thoughts?

Answer: 
You can do selection via JavaScript :

```
function getQueryVariable(variable)
{
       var query = window.location.search.substring(1);
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
}

if(getQueryVariable('course') != false) {
    $('#link_course option[value="' + getQueryVariable('course') + '"]').prop('selected', true);
}

```

[Reference](https://css-tricks.com/snippets/javascript/get-url-variables/)
You should do it in PHP:

```
<option value="BSHRTM" <?php if($course == 'BSHRTM') echo 'selected';?>>

```

*Supposing that you previsously set `$course = $_GET['course'];`*