I am looking for a way to change the value of the quantity box from the code in stead of manually changing it on the product page.
$Uitkomst
has to be in the input once the form is submitted.
I haven’t been able to find the answer to my problem so any help at all would be much appreciated.
Thanks in advance.
the value which I need in the qty input comes from this form:
<form action="?" method="POST">
<table>
<tr>
<td>
<input name="breedte" type="text" maxlength="40" placeholder="Breedte (in millimeters)" required>
</td>
</tr>
<tr>
<td>
<input name="lengte" type="text" maxlength="40" placeholder="Lengte (in millimeters)" required>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Toevoegen aan winkelwagen">
</td>
</tr>
</table>
</form>
<?php
if (isset($_POST["lengte"]))
{
$Lengte = $_POST["lengte"];
$Breedte = $_POST["breedte"];
$Uitkomst = $Lengte * $Breedte;
echo $Uitkomst;
}
?>
<div class="control">
<input
name="qty"
id="qty"
value="<?= block->getProductDefaultQty() *
1 ?>"
title="<?= $block->escapeHtmlAttr(__('Qty')) ?>"
class="input-text qty"
/>
</div>
2
Answers
I have found the solution to my problem,
in a CustomForm.phtml file I put
and in the original addtocart.phtml I put
I also put
<script src="{{MEDIA_URL}}jQuery-3.3.1.js?v=1.x"></script>
in the html head in the magento backend.this solved my problem. thanks everyone.
Changed the answer also abit.
It does not refresh the page, is that what you need?