Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8870523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:45:15+00:00 2026-06-14T17:45:15+00:00

I am trying to create a plugin, in which i wanna use repeatable input

  • 0

I am trying to create a plugin, in which i wanna use repeatable input fields in the settings page. I have found many sample codes online regarding repeatable input fields but only for post/page edit screen.

My code is here: http://pastebin.com/fiktsMrS

As you might see, i am using ‘static’ input fields

<!-- Textbox Control -->
<tr><th scope="row">Track 1</th><td><input type="text" size="200" name="fr_options[txt_1]" value="<?php echo $options['txt_1']; ?>" /></td></tr>
<tr><th scope="row">Track 2</th><td><input type="text" size="200" name="fr_options[txt_2]" value="<?php echo $options['txt_2']; ?>" /></td></tr>
<tr><th scope="row">Track 3</th><td><input type="text" size="200" name="fr_options[txt_3]" value="<?php echo $options['txt_3']; ?>" /></td></tr>
<tr><th scope="row">Track 4</th><td><input type="text" size="200" name="fr_options[txt_4]" value="<?php echo $options['txt_4']; ?>" /></td></tr>
<tr><th scope="row">Track 5</th><td><input type="text" size="200" name="fr_options[txt_5]" value="<?php echo $options['txt_5']; ?>" /></td></tr>

While all i want to do is have one input field, and an +ADD button next to it, which will create another one, and when i click save changes, it saves all the values of all the inputs.

Something similar can be found here but it seems too complicated when i only want one repeatable input field.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:45:17+00:00Added an answer on June 14, 2026 at 5:45 pm

    The PHP

    $output = '<div class="repeatable-wrap">' .
        '<ul id="tracks-repeatable" class="repeatable-fields-list">';
    if ( ! empty( $options ) ) {
        $i = 1;
        foreach( $options as $option ) {
            $output .= '<li>' .
                '<input type="text" name="fr_options[txt_'.$i.']"' .
                    'value="' . $options['txt_'.$i] .'" size="200" />' .
                '<a class="repeatable-field-remove button" href="#">REMOVE</a>' .
                '</li>';
            $i++;
        }
    } else {
        $output .= '<li>' .
            '<input type="text" name="fr_options[txt_1]" value="" size="200" />' .
            '<a class="repeatable-field-remove button" href="#">REMOVE</a>' .
            '</li>';
    }
    $output .= '</ul></div>' .
        '<a class="repeatable-field-add button" href="#">ADD</a>';
    echo $output;
    

    If your $options array contains more than just the fields you will have to tackle the above loop differently. The rest still applies.

    The jQuery

    jQuery('.repeatable-field-add').click(function() {
        var theField = jQuery(this).closest('div.repeatable-wrap')
            .find('.repeatable-fields-list li:last').clone(true);
        var theLocation = jQuery(this).closest('div.repeatable-wrap')
            .find('.repeatable-fields-list li:last');
        /* the 2 linebreaks before the .find methods
            are for presentation reasons here only */
        jQuery('input', theField).val('').attr('name', function(index, name) {
            return name.replace(/(\d+)/, function(fullMatch, n) {
                return Number(n) + 1;
            });
        });
        theField.insertAfter(theLocation, jQuery(this).closest('div.repeatable-wrap'));
        var fieldsCount = jQuery('.repeatable-field-remove').length;
        if( fieldsCount > 1 ) {
            jQuery('.repeatable-field-remove').css('display','inline');
        }
        return false;
    });
    
    jQuery('.repeatable-field-remove').click(function(){
        jQuery(this).parent().remove();
        var fieldsCount = jQuery('.repeatable-field-remove').length;
        if( fieldsCount == 1 ) {
            jQuery('.repeatable-field-remove').css('display','none');
        }
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'mt trying to create a plugin which adds a custom page in the admin
Ive been trying to create a testimonial section for a page which will have
I'm trying to create a plugin which needs to read some data from a
Hi I have been trying to create a crossfade plugin with previous and next
I'm trying to create a SVN Eclipese EFS plugin and have problems when getting
I'm trying to create a module in joomla, which uses one jquery plugin. I've
I trying to create my component which include Joomla CodeMirror plugin. I filled textarea
I am Trying to create Eclipse Plugin which has a composite with two TreeViewer
I have a project whereby I'm trying to create a distribution zip file, which
I am trying to create a function which adds additional custom data fields to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.