Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. get the value of row before changing in table if cancel click

get the value of row before changing in table if cancel click

Scheduled Pinned Locked Moved JavaScript
javascripthtmldatabasehelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ahmed_sa
    wrote on last edited by
    #1

    in my code below i can edit row success without any error but if i need to cancel value edited in row OR get value before changed what i write to cancel edit in row in table by using jquery my code as following @{ Layout = null; } Index $(function () { $("#btn").click(function () { var x = $("#txt1").val(); var y = $("#txt2").val(); var z = $("#mycountry").val(); $("#tb").append("<tr> <td>" + x + "</td> <td>" + y + "</td> <td>" + z + "</td><td> <input type='button'class='c' value='Delete'/></td><td> <input type='button' class='d' value='Edit'/></td><td><input type='button' class='e' value='Cancel'/></td></tr>"); }); $("#tb").on("click", ".c", function () { //$(this).parent().parent().remove(); $(this).closest('tr').remove(); }); $("#tb").on("click", ".d", function () { var row = $(this).closest('tr').toggleClass("editing"); row.find("td").slice(0, 2).prop("contenteditable", row.hasClass("editing")); var myselect = '<select id="mycountr1" name="mycountry1">' + '<option>---select---</option>' + '<option>Egypt</option>' + '<option>qatar</option>' + '<option>saudia</option>' + '<option>emarates</option>' '</select>'; var dropcountry = $(this).parent().prev().prev().text; $(this).parent().prev().prev().html(myselect); //$('#tb').append(myselect); // $("#tb").children().children().eq(3).children().eq(3).append("myselect"); }); $("#btndis").on('click', function () { $("body").append("<ul id='listNames''></ul>"); $('#tb td:nth-child(2)').each(function () { $("#listNames").append("<li>" + $(this).text() + "</li>") }); }); }); .editing { background: yellow; } ID Name Country:

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups