show all names found in table (tb) when click display button

Posted by Ahmedsa under jQuery on 7/21/2016 | Points: 10 | Views : 209 | Status : [Member] | Replies : 1
I need to show all names found in table tb and display as list when click button display
by jquery
by code below i can add success but how to take data from column name and show as list
this what i need actually


@{
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 = $("#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></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, 3).prop("contenteditable", row.hasClass("editing"));
});

});
</script>
<style>
.editing {
background: yellow;
}
</style>
</head>
<body>
<div>
ID<input type="text" id="txt1" /><br />
Name<input type="text" id="txt2" /><br />
Country: <select id="mycountry">
<option>---select---</option>
<option>Egypt</option>
<option>qatar</option>
<option>saudia</option>
<option>emarates</option>
</select><br />
<input type="button" value="add" id="btn" />
<input type="button" value="display" id="btndis" />

<table>
<thead>
<tr>
<td>
ID
</td>
<td>
Name
</td>
<td>
Country
</td>
<td>
</tr>
</thead>
<tbody id="tb"></tbody>
</table>
</div>
</body>
</html>





Responses

Posted by: Bhuvanesh6 on: 7/22/2016 [Member] Starter | Points: 25

Up
0
Down
I believe you are trying to bind the data from database to the UI.
Have you implemented any code to fetch the data from database and send to UI, a kind of service or CODE using entity framework.

Entity Framework:
which is responsible to get data from database and assign to model and which can be displayed in UI in entity frame work.

Web API/ Web Service
Service which will return you Json object of data from the database and assign to the UI.

Please share the C# code, if implemented.

Thanks,

Bhuvan

Ahmedsa, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response