I am coding on a page which calculates a price dynamically when changing the input field :
<input type="number" id="amount" name="amount" type="number" value="0" min="1" max="6">
The calculation is base on a php array:
$plz[01] = array( 1=> 58, 2=> 43, 3=> 32, 4=> 26, 5=> 22, 6=> 19 );
$plz[02] = array( 1=> 58, 2=> 43, 3=> 32, 4=> 26, 5=> 22, 6=> 19 );
$plz[03] = array( 1=> 58, 2=> 43, 3=> 32, 4=> 26, 5=> 22, 6=> 19 );
Im trying to parse PHP code to my script and this works:
$("#amount").on('change',function() {
var sum = <?php echo $plz[01][6]; ?>;
}
But I need the value of the selected amount as key. Something like this:
$("#amount").on('change',function() {
var sum = <?php echo $plz[01] [$(this).val();] ?>;
}
Is there a way to do this? Thanks in advance.