jQuery .post page into div problem
I'm using jquery to load a php page into a div via buttons.
The buttons are loaded through a php while function.
All of the buttons are given the id of bagView.
When the buttons are created there are also hidden input feilds with the id of equipId.
The jQuery runs when bagView is clicked. jQuery uses the hidden inputs value (which is the ID of the information i need) to grab a page usin the ID and displays the page in a div with the id of itemView.
It works great when I click the button for the first item(ID of 1), the information for ID 1 shows.. But when I click the second button(ID of 4), nothing happens. and if I refresh the page and click the second button(ID of 4), the information for ID 1 shows.
Here is the code:
jQuery:
- $('#bagView').live('click', function(){
$.post("itemInfo.php",{id: $('#equipId').attr('name')},function(data) {
$('#itemInfo').html(data);
});
});
php:
- $sql = "select * from inventory where pid='".$settings['user']['stats']['id']."' AND location='bag'";
$results = $db->db_query($sql);
while($item=$db->db_fetch_array($results)) {
$link = $item['id'];
echo '[<input type="hidden" id="equipId" name="'.$link.'" /><input type="button" value="View" id="bagView" />]';
}
#itemInfo:
- <div id="itemInfo"></div>
Any help would be great.
Thanks.