I assume you've most likely a scope problem here with the $val
variable. As you read it outside of the function
$val = $_POST[ 'val' ];
but you use it inside the function withouth importing it, it's not available there in.
So all you might need to do (the rest of the code doesn't look too wrong but it's hard to tell as I can not reproduce with your example code) is to import that variable there in. An easy way with your code is to use a closure:
$val = $_POST[ 'val' ];
add_filter( 'woocommerce_quantity_input_args',
function ( $args, $product ) use ( $val )
{
$args[ 'input_value' ] = $val; // Starting value
$args[ 'max_value' ] = 80; // Maximum value
$args[ 'min_value' ] = 1; // Minimum value
$args[ 'step' ] = 1; // Quantity steps
return $args;
}, 10, 2 );
The other alternative is to make use of the super-global inside your filter function.