Hi Everone,
I am using a page that displays a HTML table. I want to send the values to controller - This part is working fine
but along with the above table details I want to send a dropdown selected value to the controller page. How to pass the dropdown value along with table data.
$('#ddcaptical').on("change", function () {
if ($('#ddcapticaloption:selected').val() === "") {
$('#divcont').css("display", "none");
}
else {
$('#divcont').css("display", "block");
}
$('#deptid').val($('#ddcaptical option:selected').val());
var data = $.param($('#tblretant td').map(function () {
return {
name: $(this).attr('name'),
value: $(this).text().trim()
};
}));
debugger;
$.ajax({
type: "Post",
url: /Home/Stugsavedet,
data: data,
success: function (result) {
alert("Success!..");
}
});
As you can see I took all my tables values and stored in the value "data" but I need to send the "ddlcaptical" selected value to my controller
I am not using Begin form. the dropdown is outside my form. on dropdown change a ajax jquery will call the method "Stugsavedet".
[HttpPost]
public JsonResult Stugsavedet(RETGE_VM model)
{
return Json(model);
}
IN RETEGE my dropdown value name is "deptid"
public int deptid{ get; set; }
<div id="divcont"><form>
<input type="text" id="tb1" name="tbl1"/>
<table name="tbl1">
<tr><td><input type="text" name="tb2"/></td></tr>
</table>
<table name="tbl2">
<tr><td><input type="text" name="tb3"/></td></tr>
<tr><td><input type="text" name="tb4"/></td></tr>
</table>
</form></div>
@Html.DropDownListFor(model => model.tipo, listItems, "-- Select Status --", new { @id = "ddcaptical"})