Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Edit table to allow all fields show as text boxes to modify

Status
Not open for further replies.

ahm1985

Programmer
Dec 6, 2012
138
EG
Hi i have table have two buttons edit and delete
i need by jquery make edit to this tables meaning show textboxes inside table to edit
the ID,Name,Country
my code as following

@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script>

$(function () {
$("#btn").click(function ()
{
var x = $("#txt1").val();
var y = $("#txt2").val();
var z = $("#txt3").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'value='Edit'/></td></tr>");


});
$("#tb").on("click", ".c", function () {
$(this).parent().parent().remove();
});

});
</script>
</head>
<body>
<div>
ID<input type="text" id="txt1" /><br />
Name<input type="text" id="txt2" /><br />
Country<input type="text" id="txt3" /><br />
<input type="button" value="add" id="btn" />

<table id="tb">
<tr><td>ID</td><td>Name</td><td>Country</td><td><input type="button" class="c" value="Delete" /></td><td><input type="button"value="Edit" /></td></tr>
</table>
</div>
</body>
</html>

What i need to make function to edit id,name,country and show as text boxes to edit it
 
And what is it currently doing? (Or not as the case may be).

And why not put the values in input fields initially and just toggle between disabled true|false

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top