As of the select to get the data in a url link?

How to make when changing the select has changed and the link?

<div class="form-group">
<label class="col-lg-4 control-label" for="focusedInput">Select a group:
 <div class="col-lg-6">
<select class="form-control" id="taskOption_group" name="taskOption_group">
 <option value="0">- none selected -</option>
<option value="79668981">Community number 1</option>
<option value="61439844">Community number 2</option>
<option value="66162914">Community number 3</option>
<option value="71359952">Community number 4</option>
<option value="96811414">Community number 5</option>
<option value="68946366">Community No. 6</option>

So when choosing to change the link. In select can be a lot of communities.

<a href="{id}">Link</a>
June 7th 19 at 14:48
2 answers
June 7th 19 at 14:50
$('#taskOption_group').on('change', function() {
 if ($(this).val() !== '0') {
 document.location.href = '' + $(this).val();

So ?
How to make a link to display in HTML?

<a href="{id}">Link</a> - ludie commented on June 7th 19 at 14:53
document.location.href = '' + $(this).val();

$('a').attr('href '' + $(this).val());

And taking into account in finding the $('a') only the desired DOM element - Gonzalo.Hane39 commented on June 7th 19 at 14:56
June 7th 19 at 14:52
In the onchange of the select you take its value and a plus to the link.
The link to make a variable so we don't have each time to cut/replace the previous.

After the href attribute insert received earlier.

Find more questions by tags JavaScript