0
I’m studying about the Concat and priorities
The following code currently concatenates the Texts values in the field ValFin
However I would like to get the priority of Field 4 (Prival04
value 1) was less than field 2 (Prival02
with the value 2), field 4 sort 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>
You have to put the priorities in an array, sort and then have a cycle that passes in that array and fetches the value of that priority to concatenate.
– Leite