I am trying to do a unitprice,quantity, total price table. If I use table I can not get the values of quantity. However, if I don't use any tables it works and I get the quantity values.
The table codes (table.php):
<table border="1"; width="100px"; cellpadding="0"; cellspacing="0";>
<tr>
<td align="center"><b>NO</b></td>
<td align="center"><b>UNIT PRICE</b></td>
<td align="center"><b>QTY</b></td>
</tr>
Calculator code :
<h3>ATT:<h3>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Proforma</title>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script>
$(function(){
$("#click").click(function(){
$("div").each(function(index,element){
var a = $(element).find(".quantity").val();
alert (a);
});
})
});
</script>
<style>
a{
text-decoration:none;
}
input {
text-align:center
}
</style>
</head>
<body>
<?php $arr = [1,2] ?>
<?php foreach($arr as $key => $val){ ?>
<div class="prices">
<tr>
<td align="center"><?php echo $key; ?></td>
<td><input class="unitprice"; type="text"; style="width:80px"></td>
<td><input class="quantity"; type="text"; style="width:80px"; value= "100"></td>
<td><input class="totalprice"; type="text"; style="width:80px"></td>
</div>
</tr>
<?php } ?>
</table>
<input id="click"; type="submit"; value="click";>
</body>
</html>
The calculator alerts me the quantities, however if I include table.php
at the begining of calculator, it returns as undefined.
What might be the problem?