I am trying to show a booking form when I click the button using jquery toggle.
HTML
foreach($result['apiAvailableBuses'] as $value){?>
<tr>
</td>
<td><?php echo $value['fare']; ?></td>
<td>
<?php echo $value['availableSeats'].' Seats'; ?>
<input type="button" id="<?php echo $i; ?>" class="btn btn-primary" value="Book" name="Book">
</td>
</tr>
<tr class="main">
<td colspan="5">
<div class="well" id="result<?php echo $i; ?>">Booking form here</div>
</td>
</tr>
<?php $i++; } ?>
Script
$(".main").hide();
$(".btn-primary").click(function(){
var id=$(this).attr('id');
$('#result'+id).toggle();
});
But when I click on the button I can't see the booking form div
</td>tag right after the opening<tr>tag ..$i, it's not declared anywhere