In my head it was all supposed to work...but ultimately this worked
<script>
function calculateSubtotal(input, index) {
var price = parseFloat(input.value);
var quantity = parseInt(input.parentNode.nextElementSibling.innerHTML);
var subtotal = parseFloat(price * quantity);
var subtotalElement = document.getElementById("subtotal" + index);
if (price == 0) {
// If price is 0, display the hidden span with text "Not Available" in red
subtotalElement.innerHTML = "";
var notAvailableSpan = input.parentNode.previousElementSibling.querySelector("span.hidden");
notAvailableSpan.style.display = "inline";
subtotalElement.innerHTML = subtotal.toFixed(2);
} else {
var notAvailableSpan = input.parentNode.previousElementSibling.querySelector("span.hidden");
notAvailableSpan.style.display = "none";
subtotalElement.innerHTML = subtotal.toFixed(2);
updateGrandTotal()