How do i send the data to edit boxes on the same page?

前端 未结 2 349
花落未央
花落未央 2021-01-17 05:39

i have the following page generated

when i click the Edit link, the record data must be sent to the input boxes on teh same page (without refreshing the pa

相关标签:
2条回答
  • 2021-01-17 06:06

    Give you 'Edit' link a class name (say) class="edit" and handle its .click() event to update the form controls

    $('.edit').click(function() {
      var cells = $(this).closest('tr').children('td');
      $('#Code').val(cells.eq(0).text());
      $('#ProdName').val(cells.eq(1).text());
      return false; // cancel the default redirect
    });
    

    Side note: You could just replace the ActionLink() code with <a href="#" class="edit">Edit</a> and the return false; line is not necessary.

    0 讨论(0)
  • 2021-01-17 06:29

    write script for ajax call:

    $('#edit').click(function () {
             // var data = {here you will pass item.id }
            $.ajax({
                url:'ProductCategoryController/Edit', 
                data: {id : data}
                method:'GET',
                success: function (data) { 
                       //clear html page here
                       //reload html page by passing 'data' passes in function
                 //e.g. suppose html page id is 'xyz' then $("#xyz").html(data)
                      }
            });
    
        });
    
    0 讨论(0)
提交回复
热议问题