<script type="text/javascript">
$(function () {
var id = $("#id").val();
var endDate = $("#endtime_" + id).val();
$('#defaultCountdown_'+id).countdown({until: endDate});
});
</script>
while($row = mysql_fetch_assoc($result))
{
...
?>
<input type="hidden" id="id" value="<?php echo $row['id'] ?>" />
<span id="<?php echo "defaultCountdown_" . $row['id'] ?>"></span>
<input type="hidden" id="<?php echo "endtime_" . $row['id']?>" value="<?php echo $row['end_time'] ?>" />
<?php
}
Help me !!!
The problem is, you are creating your hidden inputs with the same value for the html attribute
ID:This won’t work, because ID’s have to be unique.
Modify your PHP code, to have a unique ID and additional a class name for all hidden inputs, to be able to select them all with jQuery.
Then iterate thru all hidden inputs by selecting with
$(".hiddenId"), get the ID, and start the countdown.