I am trying to figure out how to change the value of a range slider when a drop-down unit menu is changed. For example, the slider is currently set to min -29, max 43, and step size 18 for "metric" drop-down. Thus, the range slider value is: -29, -11, 7, 25, 43. When the drop-down is changed to "imperial", I would like the range slider value to change to: -20, 12, 45, 77, 110. How can I program this in JavaScript? I would like to avoid using jQuery, since I have not been able to figure that out yet. Thank you in advance for your help.
<table style="margin-left: auto; margin-right: auto;width:75%;">
<tr>
<td style="text-align:right;width:40%;">
<label for="unittype"><b>Units:</b></label>
</td>
<td style= "text-align:left;">
<select id="unitselected" style="width:40%;" onChange="getunitType()">
<option value="metric">Metric</option>
<option value="imperial">Imperial</option>
</select>
</td>
</tr>
</table>
<label id="tempunitresult" for"temp"><b>Temperature (℃):</b></label>
<br>
<input type="range" id="tempselected" class="slider" min="-29" step="18" max="43" oninput="rangeValueTemp.innerText=this.value">
<div style="text-align:center;" id="rangeValueTemp">7</div>
<script>
var unit_type = new Array();
unit_type["metric"]=0;
unit_type["imperial"]=1;
function getunitType(){
var unitType = 0;
var unitSelected = document.getElementById('unitselected');
unitType = unit_type[unitSelected.value];
if (unitType == 0){
var tempValue = document.getElementById("tempselected");
tempValue.setAttribute('min',-29);
tempValue.setAttribute('max',43);
tempValue.setAttribute('step',18);
}else{
var tempValue = document.getElementById("tempselected");
tempValue.setAttribute('min',-20);
tempValue.setAttribute('max',110);
}
</script>