JQuery to get Hidden Field Value in Table Row

Asked
Active3 hr before
Viewed126 times

6 Answers

jquerytablehiddenvaluefield
90%

Here we select an element with its name, and with Val() method we get the input hidden field value.View Demo,Get hidden field value by Id in jQuery,Get hidden field value by type in jQuery,Get hidden field value by name in jQuery

Here add an input tag hidden field with id as myInputHidden and name as myInputName.

<input id="myInputHidden" name="myInputName" type="hidden" value="Codepedia" />
load more v
88%

your selector starts with tr:first > .wrapperDivHidden ... but .wrapperDivHidden is not an immediate child of tr so change your selector like so:,Here is an over simplified example of what you are trying to do:,Connect and share knowledge within a single location that is structured and easy to search.,To learn more, see our tips on writing great answers.

your selector starts with tr:first > .wrapperDivHidden ... but .wrapperDivHidden is not an immediate child of tr so change your selector like so:

$(this).parents('tr').find('.wrapperDivHidden input[type="hidden"]').val();
load more v
72%

Site Bugs / Suggestions ,Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. ,View Unanswered Questions, help? What is 'CodeProject'? General FAQ Ask a Question Bugs and Suggestions Article Help Forum About Us

foreach (var del in approvedList)
 {         
   <tr>
    <td>@del.CampaignName</td>
    <td>@del.Name</td>                           
    <td>@del.ApprovalStatus</td>                            
    <td>  
    <div id="hiddenWrapper" class="row">
      <div class="col-sm-5"><input type="hidden" id="id" name="id" value="@del.PayoutId" />
          <input id="btnApprove" name="btnApprove" class="btn  btn-success" type="button" title="Approve" value="Approve" onclick="location.href='@Url.Action("PayoutApproval", "Account", new { id = @del.PayoutId })'" />
      </div>                                                                
    </div>                                                                                        
  </td>
 </tr>
 }
 $('#btnApprove').click(function() {
    $("#btnApprove").prop("disabled", true);
    console.log("id field value: " + $("#id").val());
    $.ajax({
       url: '/Account/PayoutApproval',
       type: "POST",
       data: JSON.stringify({
          id: $("#id").val()
       }),
       dataType: "json",
       contentType: 'application/json, charset=utf-8',

       success: function(result) {

          if (result.f != null) {
             swal(result.f, "!", "error");
             $("#btnApprove").prop("disabled", false);

          } else {
             swal({
                title: "Success!",
                text: result.s,
                type: "success"
             });
             $('#action').prop('disabled', true).trigger("chosen:updated");
             $("#submitBrdFrm").prop("disabled", true);
             top.location.href = workListUrl;
          }
       }

    });

    return false;
 });
load more v
65%

I have a div where i have multiple divs and in that i have a hidden field where i will be getting ids in that hidden field i need to that hidden field selected row value using jquery how can i do this,this is the code that i used to get hidden field value,i am getting 1 st row id value but if i am clicking on second row i need to get second row id value but its getting only first row id

I have a div where i have multiple divs and in that i have a hidden field where i will be getting ids in that hidden field i need to that hidden field selected row value using jquery how can i do this

<div id="divmain" style="width:100%" class="Table brd">
        @foreach (var items in list)
        {
            <div class="row" style="width:100%">
                <div class="test">

                    @if ((items.Name != null))
                    {
                        <p>  </p>
                    }
                    else
                    {
                        <p> N/A </p>
                    }
                </div>
                <div class="test">

                    @if ((items.Rollno!= null))
                    {
                        <p>  </p>
                    }
                    else
                    {
                        <p> N/A </p>
                    }
                </div>
                <div class="test">

                    @if ((items.id== true))
                    {
                       <input type="button" id="BtnView" class="View BtnClsView" title="View" style="width: 100px;"/>
                    }
                    else
                    {
                        <p> N/A </p>
                    }
                </div>
                <div class="test">
                    <input type="hidden" value="@Model.Id" id="HdnId" />
                </div>
            </div>
        }
    </div>

this is the code that i used to get hidden field value

var HdnvalId = $("#HdnId").val();
load more v
75%

var hv = $('#h_v').val();
load more v
40%

I have a table with a hidden field in each row. I need to Alert the value of hidden field when a button in that row is clicked. I have the following jQuery code. But it does not work. How do we make it work?,your selector starts with tr:first > .wrapperDivHidden ... but .wrapperDivHidden is not an immediate child of tr so change your selector like so:,It is indeed the createPopup method that does the trick. It's a proprietary method in Internet Explorer.,In VanillaJS you can use document.querySelectorAll() and walk over the rows using forEach()

CODE: http://jsfiddle.net/Lijo/xWanB/

<script>
    $(document).ready(function () {

        //"Show ID" for Associate Button Click
        $('.resultGridTable tr > td > .actionButtonNational').click(function () {
            //"this" means show ID button
            //Traversing to get the parent row and then the required columns in the row
            var associateID = $(this).parents('tr:first > .wrapperDivHidden input[type=hidden]').val();
            alert(associateID);
            return false;
        });
    });
</script>

HTML

<td>
   XXXXX
   <input type="submit" name="ctl00$detailContentPlaceholder$grdSubscribedAssociates$ctl04$btnNational" value="Show ID" id="detailContentPlaceholder_grdSubscribedAssociates_btnNational_2" class="actionButtonNational" style="color: White; background-color: #A7A7A6;
                        font-weight: bold; width: 60px" />
   <div id="wrapperDivHidden" class="wrapperDivHidden">
      <input type="hidden" name="ctl00$detailContentPlaceholder$grdSubscribedAssociates$ctl04$hdnAssociateID" id="detailContentPlaceholder_grdSubscribedAssociates_hdnAssociateID_2" value="789345680" />
   </div>
</td>
load more v

Other "jquery-table" queries related to "JQuery to get Hidden Field Value in Table Row"