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);
});
});
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.