Support

Account

Home Forums Add-ons Repeater Field Product List Reply To: Product List

  • Ok this is now sovled 🙂 and works well for me it does just a little playing around. Mediawerk thanks for help, I had a feeling that I would have to use js in so form. Little change to the code you provided but really help me a lot, thank you!

    My code is below on html output I used and the JS.

    Outputs the html

    <?php 
    $rows = get_field('product_range');
    if($rows){
    	echo '<select id="quantity" name="quantity" required>';
    		foreach($rows as $row){
    			echo '<option name="' . $row['product_quantity'] . '" value="' . $row['product_quantity'] . '" data-price="' . $row['product_price'] . '">' . $row['product_quantity'] . '</option>';
    		}
    	echo '</select>';
    	echo '<span class="price-text"></span>';
    }	
    ?>

    JS used

    $(document).ready(function(){
    	$("#quantity").change(function() {
    		var price = $("#quantity option:selected").data("price");
    	jQuery(".price-text").text(price);
    	});
    });