title: How To get Selected Radio Button Value in Mvc
body: <p>I am trying to create a simple rating system in MVC just for learning. My problem is that I am not able to get the radio button selected value I am trying to pass it to the controller. Any help will be appreciated.</p>
  
  <p>Here is my code:</p>
  
  <pre class="lang-html prettyprint-override"><code>@model WebApplication1.ViewModel.ViewModelRatingAndReviews
  &lt;script src="~/Scripts/jquery-1.10.2.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $("#btn-gn").click(function () {
              var RatingStar = $("input[name=star]:checked").val()
              $.ajax({
                  url: '@Url.Action("GiveReview", "ProvideReview")',
                  type: 'GET',
                  data: {"RatingStar": RatingStar },
                  success: function (result) {
                      //alert("success");
                      console.log("click");
                  },
                  error: function (result) {
                      alert("error!");
                  }
              });   //end ajax
          });
      });
  &lt;/script&gt;
  @using (Html.BeginForm("GiveReview", "ProvideReview", FormMethod.Post, new { Id = "ratingsForm" }))
  {
      @Html.AntiForgeryToken()
      &lt;div class="wrapper"&gt;
          &lt;div class="container"&gt;
              &lt;div class="mid-content"&gt;
                  @* Header Title Starts *@
                  &lt;div class="row"&gt;
                      &lt;div class="col-md-12"&gt;
                          &lt;div class="title-head"&gt;
                              &lt;h3&gt;&lt;span class="mid-content-head"&gt;Provide Ratings&lt;/span&gt;&lt;/h3&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  @* Header Title Ends *@
              &lt;/div&gt;
                  &lt;div class="row"&gt;
                      &lt;div class="col-md-12"&gt;
                          &lt;div class="l-search"&gt;
                              @* For UID *@
                              &lt;div class="row"&gt;
                                  &lt;div class="col-md-3"&gt;
                                      &lt;span class="profile-name"&gt;UserId&lt;/span&gt;
                                  &lt;/div&gt;
                                  &lt;div class="col-md-3"&gt;
                                      @Html.TextBox("UserId")
                                  &lt;/div&gt;
                              &lt;/div&gt;&lt;br /&gt;
                              @* UID Ends *@
                              &lt;div class="row"&gt;
                                  &lt;div class="col-md-3"&gt;
                                      &lt;span class="profile-name"&gt; Select Your Ratings&lt;/span&gt;
                                  &lt;/div&gt;
                                  &lt;div class="col-md-2"&gt;
                                      &lt;div class="stars"&gt;
                                          &lt;input type="radio" name="star" class="star-1" id="star-1" value="1"/&gt;
                                          &lt;label class="star-1" for="star-1"&gt;1&lt;/label&gt;
                                          &lt;input type="radio" name="star" class="star-2" id="star-2" value="2"/&gt;
                                          &lt;label class="star-2" for="star-2"&gt;2&lt;/label&gt;
                                          &lt;input type="radio" name="star" class="star-3" id="star-3" value="3"/&gt;
                                          &lt;label class="star-3" for="star-3"&gt;3&lt;/label&gt;
                                          &lt;input type="radio" name="star" class="star-4" id="star-4" value="4"/&gt;
                                          &lt;label class="star-4" for="star-4"&gt;4&lt;/label&gt;
                                          &lt;input type="radio" name="star" class="star-5" id="star-5" value="5"/&gt;
                                          &lt;label class="star-5" for="star-5"&gt;5&lt;/label&gt;
                                          &lt;span&gt;&lt;/span&gt;
                                      &lt;/div&gt;
                                  &lt;/div&gt;
                              &lt;/div&gt;&lt;br /&gt;
  
  
                              @* For Consumer Name *@
                              &lt;div class="row"&gt;
                                  &lt;div class="col-md-3"&gt;
                                      &lt;span class="profile-name"&gt;Consumer Name&lt;/span&gt;
                                  &lt;/div&gt;
                                  &lt;div class="col-md-3"&gt;
                                      @Html.TextBox("Consumername")
                                  &lt;/div&gt;
                              &lt;/div&gt;&lt;br /&gt;
                              @* Consumer Name Ends *@
  
                              @* For Review Header *@
                              &lt;div class="row"&gt;
                                  &lt;div class="col-md-3"&gt;
                                      &lt;span class="profile-name"&gt;Enter Review Subject&lt;/span&gt;
                                  &lt;/div&gt;
                                  &lt;div class="col-md-3"&gt;
                                      @Html.TextBox("Consumername")
                                  &lt;/div&gt;
                              &lt;/div&gt;&lt;br /&gt;
                              @* Review Header Ends *@
  
                              @* For Review Header *@
                              &lt;div class="row"&gt;
                                  &lt;div class="col-md-3"&gt;
                                      &lt;span class="profile-name"&gt;Enter Review Content&lt;/span&gt;
                                  &lt;/div&gt;
                                  &lt;div class="col-md-3"&gt;
                                      @Html.TextArea("ReviewContent")
                                  &lt;/div&gt;
                              &lt;/div&gt;&lt;br /&gt;
                              @* Review Header Ends *@
  
  
                          &lt;/div&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
             @* Button Area Starts*@
              &lt;div class="lender-search"&gt;
                  &lt;button type="submit" id="btn-gn"&gt;Submit&lt;/button&gt;
                  &lt;button type="reset"&gt;Clear&lt;/button&gt;
              &lt;/div&gt;
              @* Button Area Ends *@
          &lt;/div&gt;
          &lt;/div&gt;
          }
  </code></pre>
  
  <p>Controller</p>
  
  <pre><code>public ActionResult GiveReview()
  {
      ViewModelRatingAndReviews viewModelRatingAndReviews = new ViewModelRatingAndReviews();
      return View(viewModelRatingAndReviews);
  }
  
  [HttpPost]
  public ActionResult GiveReview(int UserId, int RatingStar, string ConsumerName, string ReviewHeader, string ReviewContent)
  {
      ViewModelRatingAndReviews viewModelRatingAndReviews = new ViewModelRatingAndReviews();
      viewModelRatingAndReviews.InsertRating(UserId, RatingStar, ConsumerName, ReviewHeader, ReviewContent);
      return View("SubmittedReview",viewModelRatingAndReviews);
  }
  </code></pre>