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>';
}