I'm displaying data from mysql db in while loop name with edit and cancel buttons. when i click on edit button my span data is stored in input text and if i click on cancel its storing back my label data to input text..i'm only able to inline edit my first row record not on 2nd row or 3rd row for other rows my edit button is not pushing my span data into input text!!
Its like inline jquery/php edit for all rows were is should be able to edit individual records!!
Any help is appricated Thanks!!
Code
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
$('#orders').delegate('.editOrder','click',function(e){
e.preventDefault(e);
var $li = $(this).closest('li'); $li.find('input.name').val($li.find('span.name').html());
$li.addClass('edit');
});
$('#orders').delegate('.cancelEdit','click',function(e){
e.preventDefault(e);
$(this).closest('li').removeClass('edit');
});
</script>
<style type="text/css">
ul li .edit{
display:none;
}
ul li.edit .edit{
display:initial;
}
ul li.edit .noedit{
display:none;
}
</style>
</head>
<body>
<?php
$sql = "select * from demo";
$result = mysql_query($sql);
while($row = mysql_fetch_object($result))
{
?>
<ul id="orders">
<li>
<span class="noedit name">
<?php echo $row->name;?>
</span>
<input class="edit name"/>
<button class="editOrder">Edit</button>
<button class="cancelEdit">Cancel</button>
</li>
</ul>
<?php } ?>
</body>
</html>