I'm studying about concat and priorities
The following code currently concatenates the values of the texts in the ValFin
field
However, I would like that if the priority of field 4 (% with% with value 1) was less than that of field 2 (% with% with value 2), field 4 was ordered first
function teste(){
var a = document.getElementById('val01').value;
var b = document.getElementById('val02').value;
var c = document.getElementById('val03').value;
var d = document.getElementById('val04').value;
var f = a.concat(b).concat(c).concat(d);
document.getElementById("ValFin").value = f;
console.log(document.getElementById("ValFin").value);
}
<html>
<head>
</head>
<body>
<label>Valor 01</label>
<input id="val01" type="text" />
<label>Prioridade do Valor 01</label>
<input id="Prival01" type="text" maxlength="1" /> <br>
<label>Valor 02</label>
<input id="val02" type="text" />
<label>Prioridade do Valor 02</label>
<input id="Prival02" type="text" maxlength="1" /> <br>
<label>Valor 03</label>
<input id="val03" type="text" />
<label>Prioridade do Valor 03</label>
<input id="Prival03" type="text" maxlength="1" /> <br>
<label>Valor 04</label>
<input id="val04" type="text" />
<label>Prioridade do Valor 04</label>
<input id="Prival04" type="text" maxlength="1" /> <br>
<br>
<button id="Calc" onclick="teste();">FuncaoMontar</button>
<input id="ValFin" type="text" />
</body>
</html>