Support

Account

Home Forums Add-ons Repeater Field Selecting specific rows from Repeater fields

Helping

Selecting specific rows from Repeater fields

  • I’m trying to build a calculator that has a dropdown menu with the ‘loan_type’ and ‘rate’ field in the dropdown which I did.

    But I’m stuck on the next step. I want it to display an input field with the ‘loan_amount_mid’ field based on the option picked in the dropdown.

    <p>
       <label>Loan Type:</label>
       <select class="rate">
          <?php while( have_rows('loan_calculator') ): the_row(); 
             $title = get_sub_field('loan_type');
             $rate = get_sub_field('rate');
             ?>
          <option value="<?php echo $rate; ?>"><?php echo $title; ?> - <?php echo $rate; ?></option>
          <?php endwhile; ?>
       </select>
    </p>
    <div class="accrue-field-amount">
       <p><label>Loan Amount: </label>
          <?php while( have_rows('loan_calculator') ): the_row(); 
             $mid = get_sub_field('loan_amount_mid');
             ?>
          <input type="text"value="<?php echo $mid; ?>" step="1000" class="amount">
          <?php endwhile; ?>
       </p>
    </div>

    As displayed it obviously just displays all the rows in the loop. How could I go about this?

    Thanks.

  • The only way you could do this would be to make each row conditional, and I don’t thing that’s possible. I also don’t think that it would give you the results that you want because if all the fields of the repeater are not submitted than the missing rows will be deleted. I’m not sure what you’re trying to achieve. It might be possible to create some custom JavaScript (jQuery) to hide the rows based on the selection.

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Selecting specific rows from Repeater fields’ is closed to new replies.