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 6704541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:18:02+00:00 2026-05-26T07:18:02+00:00

When I click on buttons I generate some inputs field with custom attributes like

  • 0

When I click on buttons I generate some inputs field with custom attributes like that :

<input type='text' name='field["+ i++ +"]' value='' data-kind='title' />
<input type='text' name='field["+ i++ +"]' value='' data-kind='video' />
<input type='text' name='field["+ i++ +"]' value='' data-kind='text' />

I retrieve the ‘name’ value with a foreach loop in PHP :

$result = array_combine($num, $records);

    foreach ($result as $rank => $content)
    {
        $data = array(
            'content' => $content,
            'post_id' => $post_id,
            'rank' => $rank,
            'type' => $this->input->post('field_type') // HERE
            );
                echo '<pre>';print_r($data);echo '</pre>';
    }

To get the ‘type’ I do a $this->input->post('field_type'); which is given by this :

var field_type = $(":input[data-kind]").attr('data-kind');
$("#field_type").val(field_type' ');

and :

echo '<input type="hidden" id="field_type" name="field_type" value="" />';

But it only returns me the last ‘data-kind’ value not each one :/

Now i just need to loop the ‘data-kind’ value for each input fields and retrieve them in my foreach loop

Any help would be very very appreciated !!


Many thanks for your answers, it helped me a lot! But now how can I add the result in my current foreach at ‘type’ data :

$result = array_combine($num, $records);

    foreach ($result as $rank => $content)
    {
        $data = array(
            'content' => $content,
            'post_id' => $post_id,
            'rank' => $rank,
            'type' => // HERE I NEED EACH ATTRIBUTE VALUE
            );
                echo '<pre>';print_r($data);echo '</pre>';
    }
  • 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-05-26T07:18:03+00:00Added an answer on May 26, 2026 at 7:18 am

    If you want to place all of the data-kind values in the #field_type field, you need something like this:

    var fieldTypes = [];
    $("input[data-kind]").each(function()
    {
        fieldTypes.push( $(this).attr('data-kind') );
    });
    $("#field_type").val(fieldTypes.join(','));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three radio buttons with same name and different values.When I click the
there are some buttons on the top of the winform, and when I click
In my application I have some link buttons there but when I right click
I have a page with some dynamically added buttons. If you click a button
I have some radio buttons and I'd like to have different hidden divs show
I have one form in JSP. I have some input fields in that page,
Hello I'm trying to dynamically generate some inputs for my form, but it's not
I need to generate some values on Javascript, by clicking on a button, that
For some reason i have to put all input field into array.Because the input
I have a form that generates new input fields via JavaScript on click. the

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.