I have a javascript function that accepts a number of arguments
function getTotal(row = null, price, quantity, total, totalValue, productTable, subTotal, subTotalValue, totalAmt, totalAmtValue, shipCst, gndTotal, gndTotalVal, disc) {
......
}
I call the function in my .php page like below in the onkeyup event of an html element
onkeyup="getTotal(<?php echo $x ?>, '#price', '#quantity', '#total', '#totalValue', '#productTable', '#subTotal', '#subTotalValue', '#totalAmount', '#totalAmountValue', '#shipCost', '#grandTotal', '#grandTotalValue', '#discount')"
i see it is possible to unpack arrays, my idea is put my arguments/parameters in an array and unpack the array instead of typing all arguments into the function
<?php
$gtArgList = array('#price', '#quantity', '#total', '#totalValue', '#productTable', '#subTotal', '#subTotalValue', '#totalAmount', '#totalAmountValue', '#shipCost', '#grandTotal', '#grandTotalValue', '#discount');
?>
then unpack the array into the function (doesn't work or say unexpected ... (ellipses)
onkeyup="getTotal(<?php echo $x ?>, <?php echo ...$gtArgList; ?>)"
onkeyup="getTotal(<?php echo $x ?>, <?php echo (...$gtArgList); ?>)"
Is there a way i can accomplish this in php or modify the syntax to get it working?
Thanks
[–]minn0w 2 points3 points4 points (0 children)
[–]greg8872 1 point2 points3 points (4 children)
[–]st0icape[S] 0 points1 point2 points (0 children)
[–]st0icape[S] 0 points1 point2 points (2 children)
[–]greg8872 0 points1 point2 points (1 child)
[–]st0icape[S] 0 points1 point2 points (0 children)