Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3808152
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:06:12+00:00 2026-05-19T15:06:12+00:00

My table is : <script type=text/javascript> $(.icon_add).live(click, function(e) { e.preventDefault(); var $link = $(this);

  • 0

My table is :

<script type="text/javascript">
 $(".icon_add").live("click", function(e) {
                e.preventDefault();
                var $link = $(this);
                var docid = $($(this).parent().children("input[type=hidden][id=DocId]")[0]).val();
                var doctitle = $($(this).parent().children("input[type=hidden][id=DocTitle]")[0]).val(); // For getting the value of 'DocTitle' - undifined
                alert(doctitle);
                var grpid = $('#BldGrpId').val();
                var contents = '<li><span class="remove_item"><a href="#"> &nbsp;</a>' + doctitle + '</li>';
                $("#LstBldDoc").append(contents);
                $("#LstDocTemp tr[id='" + docid + "']").remove();
                $.post("/BuildGroup/EditDocTempForBldGrp", { docId: docid, bldGrpId: grpid });
            });
   </script>
<table id="LstDocTemp" class="grid_view" border="0" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr>
                        <th class="selct_column" align="left">
                            &nbsp;
                        </th>
                        <th class="selct_column" align="left">
                            <input name="checkbox6" id="chkSelectAll" type="checkbox" />
                        </th>
                        <th class="doc_title_1" align="left">
                            Document title
                        </th>
                        <th class="description" align="left">
                            Description
                        </th>
                        <th class="revision" align="center">
                            Revision
                        </th>
                        <th class="part_no" align="left">
                            Parts name
                        </th>
                        <th class="issue_no" align="center">
                            Issue
                        </th>
                        <th class="actions" align="center">
                            Actions
                        </th>
                    </tr>
                    <% int slNo = 1; %>
                    <%foreach (var item in Model)
                      { %>
                    <tr id="<%= Html.Encode(item.DocId) %>">
                        <td>
                            <%--<%= slNo %>--%>
                        </td>
                        <td>
                            <input type="checkbox" name="chkItem" class="chk" id="chkbox_<%=Html.Encode(item.DocId) %>" />
                        </td>
                        <td>
                            <%= Html.Hidden("DocTitle", item.DocTitle)%>
                            <a href='<%= Url.Action("DetailsDocumentTemplate", "Document", new { id = item.DocId })%>'>
                                <%=Html.Encode(item.DocTitle) %></a>
                        </td>
                        <td align="left">
                            <%--<%= Html.Hidden("DocDesc", item.DocDesc)%>--%>
                            <%= Html.Encode(item.DocDesc) %>
                        </td>
                        <td align="center" class="dark_highlight">
                            <%--<%= Html.Hidden("DocRevision", item.DocRevision)%>--%>
                            <%= Html.Encode(item.DocRevision) %>
                        </td>
                        <td align="left">
                            <%= Html.Hidden("PartListId", item.PartListId)%>
                            <%--<%= Html.Hidden("PartNo", item.PartNo)%>--%>
                            <%= Html.Encode(item.PartNo) %>
                        </td>
                        <td align="center" class="light_highlight">
                            <%--<%= Html.Hidden("IssueNo", item.IssueNo)%>--%>
                            <%=Html.Encode(item.IssueNo) %>
                        </td>
                        <td align="center">
                            <%= Html.Hidden("DocId", item.DocId)%>
                            <a class="icon_add" title="Add">Add</a>
                        </td>
                    </tr>
                    <%slNo++;
                      } %>
               </tbody>
            </table>

Here the alert(doctitle); is poping “undefined”. I need to get value of DocTitle (hidden field) when “addSelected” is clicked.

Please can anyone help me out of this??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T15:06:13+00:00Added an answer on May 19, 2026 at 3:06 pm

    You cannot use the same ID multiple times – but apparently you are doing that since you are using a static id in a loop. Doing so basically breaks everything – you cannot expect selectors to work properly with duplicate IDs.

    After fixing this, the following code should work to get the value of the hidden field:

    $link.closest('tr').find('input:hidden[name=DocTitle]').val();
    

    Explanation: First climb up the DOM tree starting at $link until the current element is <tr>. Then search for hidden input fields with the given name and get its value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function msg ($msg) { echo <script type='text/javascript'>alert('$msg');</script>; } if (count($_POST)) { msg('TEST!!!!!'); } <!DOCTYPE
I have an inline script on my page as such: <script type=text/javascript> var rootPath
<!DOCTYPE html> <html lang=en> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js type=text/javascript></script> <script type=text/javascript>
I have a script that takes a table name and generates a control file
How to script a constraint on a field in a table, for an acceptable
I am working on a script to send data to a mysql table and
Currently, if I want to output a SQL script for a table in my
OP, please replace this text with a detailed description of your problem. Your code
I wrote simple custom validation on javascript based on this doc . I want
when user insert text input i wish get, and insert in link. How that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.