I have a variables from my database called MSRP price and I need to loop through the functions for every product showed. What I would like to do is take the Database value and pass it to the variable and output the results on each product on the same page.
<html>
<body>
<script>
function myFunction(msrp) {
var today = 6;
var text = "";
var i;
for (i = 1; i <= 10; i++) {
var profits=msrp * ((100-(i*10))/100)
if (i == today) {
text += "Today $" + profits.toFixed(2) +"<br>";
} else {
text += "Day " + i + " $ " + profits.toFixed(2) +"<br>";
}
document.getElementById("demo").innerHTML = text;
}
}
</script>
<!-- Products -->
@foreach ($products as $product)
<script>
myFunction($product[msrp]);
</script>
@endforeach
</body>
</html>