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.
The PHP
If your
$optionsarray contains more than just the fields you will have to tackle the above loop differently. The rest still applies.The jQuery