jquery - Retrieve multiple model values from radio button asp.net c# mvc4 -


i have razor table generated customer model. put radio-button table user select customer want, have action bar @ top of table, i'm looking able retrieve both customer id , customerfirstname field using 1 radio-button. possible jquery or c#? right have radio-button getting customer's id not name. if unique customer name field can use jquery ajax post pass these 2 fields controller. ideas?

here radio-button html:

`<input type="radio" class="radiobtnclass" name="selectedcustomer" value="@item.id" />` 

also have field:

`<input type="hidden" id="hdncustomerid" />` 

then of action bar actions edit:

    `<li>@ajax.actionlink("edit", "edit", new { id = "0" }, new ajaxoptions { httpmethod = "get" },       new { @class ="opendialog", data_dialog_id = "aboutldialog",       data_dialog_title = "edit", id = "btneditcustomerid" })</li>` 

the jquery function changes radio-button selected:

    jquery(document).ready(function () {     jquery('input[type=radio]').change(function () {         jquery('#hdncustomerid').val($(this).val()); 

but requires customer id, want create link gets id , firstname field.

figured out, used ajax string controller:

jquery:

var customerid = jquery('#hdncustomerid').val();         var customername = null;         $.ajax({             url: '/customer/getcustomername',             data: { id: customerid },             type: "get",             async: false,             cache: false,             success: function (data) {                 customername = data             }         }); 

controller method:

public string getcustomername(int id)     {         customer customerobj = _customer.getcustomer(id);         string customername = customerobj.firstname + " " + customerobj.lastname;         return customername;     } 

Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -