Are there potential pitfalls in trying to achieve automatic display of associated values without using JavaScript in PHP?

When trying to achieve automatic display of associated values without using JavaScript in PHP, one potential pitfall is the need to refresh the page every time a selection is made, which can lead to a poor user experience. To solve this, you can use PHP to dynamically generate the associated values based on the selected option without the need for a page refresh.

<select name="fruit" id="fruit">
    <option value="apple">Apple</option>
    <option value="banana">Banana</option>
    <option value="orange">Orange</option>
</select>

<?php
$fruitPrices = [
    'apple' => '$1.00',
    'banana' => '$0.50',
    'orange' => '$0.75'
];

if(isset($_POST['fruit'])){
    $selectedFruit = $_POST['fruit'];
    echo 'Price: ' . $fruitPrices[$selectedFruit];
}
?>