kishankakadiya kishankakadiya - 2 years ago 132
jQuery Question

dynamically edit row using jquery

I am perform add ,edit and delete operation using jquery.

i have create product.html file and jsproduct.js file.

enter image description here

My Question is i am click edit button and change selectbox value and press edit
product button

but select box value can not display table

<script async src="//"></script>

Check Demo

Answer Source

The problem is that you are using the same id for the <td>elements on your table. You are using the counter with this and the result is having more than one <td id="1"> and jQuery will not handle it correctly.

I changed your td's to use a class instead of id and added a class prefix to your td's like this:

'<td class="category-' + this.counter + ' ">' + product_category +'</td>'
'<td class="name-' + this.counter + '">' + product_name + '</td>'

And in your edit function I used the class as a selector:

$(".category-" +;
$('.name-' +;

Then it works correctly. You still have some trouble in setting your mode etc but hopefully you can get those fixed by yourself.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download