<script type="text/javascript">
$(function () {
debugger;
$('#table1').on('click', 'tr', function () {
debugger;
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
}
else {
$('#table1', 'tr.selected').removeClass('selected');
$(this).addClass('selected');
}
var row = $(this);
debugger;
var Type = row.find('td')[0].firstChild.data;
var info = row.find('td')[1].firstChild.data;
var s = {};
s. =Type;
s.info =info;
alert(JSON.stringify(s));
});
$('[ID*=btnadd]').on('click', function () {
var Type = $("#table1 tr.selected").find('td:eq(0)').html();
var info = $("#table1 tr.selected").find('td:eq(1)').html();
s = {};
s. Type = Type;
s. info = info;
alert(JSON.stringify(s));
get(s);
});
});
debugger;
function get(s) {
var ins = {};
ins. Type = s.Type;
ins. info = s.info;
$.ajax({
type: "POST",
url: "M.aspx/insert",
contentType: "application/json;charset=utf-8",
data:JSON.stringify(ins),
dataType: "json",
success: function (result) {
var insertd = JSON.parse(result.d).response;
debugger;
$('[ID*=btnadd]').on('click', function () {
$("#type_txt").val(ins.Type);
$("#value1_txt").val();
$("#value2_txt ").val();
$("#value3_txt ").val();
});
},
error:function(error)
{
var r = error.responseText;
var errorMessage = r.Message;
alert(errorMessage);
alert(r);
alert("error");
}
});
};
</script>