Hello ...

i have a table which has one button i need to send the id of that record in the table to the next page the will be directed to once i click the butoon i don't want to send it in the url ... so what i did is i tried to add the id in a hidden celli in my table and once i click my button i get it as req.body.hiddenId , but this is not working ...check below code ...

<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

</head>

    <body >
        <%- include("header") %>
       <div>
           <h2 style="text-align: center; font-family: 'Courier New', Courier, monospace; font-weight: bold;font-size: 50px; ">
            <%=title%>
             </h2>

               <div class="row justify-content-center">
                <div class="col-auto">
                <!-- <a type="button" class="btn btn-success"href="/add_help_family">help</a> -->
                <br/>
                <br/>

               <table class="table table-dark table-striped ">
                   <thead>
                       <tr>
                           <th style="display:none;"></th>
                           <th>name</th>
                           <th>school value</th>

                       </tr>
                   </thead>
                   <tbody>
                       <%families.forEach(function(user){ %>
                        <tr>
                            <td style="display:none;" name="hiddenId" value="<%= user.familyId %>" ></td>
                            <td data-label="name"><%= user.name %></td>

                            <td data-label="schoolPaymentValue"><%= user.schoolPaymentValue %></td>

                            <td>

                                <a href="/helpFamilyForm" class="btn btn-sm btn-danger">New Help</a>
                            </td>

                        </tr>
                        <% }); %>

                   </tbody>
               </table>
               </div>
               </div>



       </div>
    </body>
</html>


--------------------------------------------------------------------------------------



app.get('/helpFamilyForm', (req, res)=>{
    var id = req.body.hiddenId;
    console.log("El id Hna : ",id);
    res.render('help_family_form',{
        title:"ZZZ",
        id : id
        }
        )

});

when i console log the id i got it undefined ...........

so what is wrong here ???

thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.