I have a Javascript function within a row in a foreach loop. I'd like to have it repeat each row and have tried this code. Each row has a element ID baserate which will be converted using the code below.
My problem is that it works only on the first row and doesn't for the rest. I do need some help to solve this, and any help is appreciated.
PHP:
foreach ($alllocs as $allrows) - no need to put complete code here.
JAVASCRIPT:
<script>
for (var i = 0; i < <?php echo $alllocs; ?>.length; i++) {
var a = document.getElementById("baserate").value;
var e = Number(a).toFixed(2);
var b = Number(forex.rates.KRW).toFixed(2);
var c = e * b;
document.getElementById("welkomet").innerHTML = (c).toFixed(2);
}
</script>
$alllocs
contains an array of PHP objects and you want to access the$alllocs
in Javascript? Is that what you meant? – Aprian 20 hours agoJavascript Object
– Aprian 20 hours ago