I am creating a popup dialog box where I need to put a set of values in hidden format, but when I am getting the value in AJAX post, I am getting only last value.
this is the PHP part:
$plan_ids=array();
foreach($test_plan as $plan)
{
$plan_ids[]=$plan['plan_id'];
}
?>
<?php
foreach($plan_ids as $id)
{
echo "<input type='hidden' id='plan_id' value='$id'>";
}
//var_dump($plan_ids);
// echo $plan['plan_id'];
?>
In the AJAX part I am doing:
$("#save").click(function () {
var name = $('#name').val();
var id = $('#release_id').val();
var plan_id = $('#plan_id').val();
//alert('hello');
$.ajax({
type: 'POST',
url: '/api/api.php?action=put_iteration&name=' + name + '&id=' + id + '&plan_id=' + plan_id,
data: "name=" + name + "&id=" + id + "&plan_id=" + plan_id,
success: function () {
$('#save').hide(function () {
$('div.success').fadeIn();
});
}
});
});
I'm clueless about HTML hidden fields.