I found this code snippet online and used it in my function.
Surprisingly, it works perfectly.
However, I'm puzzled by the use of .length in the for loop statement.
Isn't length a measurement of how long something is?
It's somewhat like the word width, isn't it?
So, why are we measuring the length of a radio button to check if it exists? What kind of length is being referred to here?
function monte(fichier_c)
{
var boutonRadio = document.getElementsByName("id_ordre_transport");
var monte = "rien";
for (var i = 0; i < boutonRadio.length; i++)
{
if (boutonRadio[i].checked)
{
//alert(fichier_c);
//alert(boutonRadio[i].value);
//alert( "#monte"+boutonRadio[i].value);
var monte = fichier_c+"#monte"+boutonRadio[i].value;
}
}
if ( monte == "rien" )
{
//alert(fichier_c);
var monte = fichier_c;
}
return monte;
}
Could someone please provide clarity on the purpose of this 'length' parameter?