ahmed salah

ahmed salah

  • 1.2k
  • 547
  • 66.9k

how to pass data from table html to bootstrap model ?

Jun 22 2023 12:05 PM

when pass data from table html to bootstrap model it not passed so what is issue i don't know

i need to pass server ip and location and printer name and id to bootstrap model 

it  display perfect on table html but it not passed to bootstrap model 

so what is issue and how to solve it please

<div class="modal fade" id="editshelflabelModal" tabindex="-1" role="dialog" aria-labelledby="userDetailsModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered" role="document">
        <div class="modal-content">
            <h5 class="modal-title" style="text-align:center;">
                

            </h5>
          
                    <div class="form-group">
                        <label for="edit-printer">Printer Name</label>
                        <input type="text" class="form-control" id="edit-printername" name="printername">
                    </div>
                    <div class="form-group">
                        <label for="edit-locationsdata">Location Name</label>
                        <input type="text" class="form-control" id="edit-Location" value="save" name="Location">
                    </div>
                </form>
                @*<div class="form-group row">
                    <label for="serverIp" class="col-sm-1 col-form-label" style="font-size:15px;font-family: 'Open Sans', sans-serif;font-weight: bold;">Server IP</label>
                    <div class="col-sm-3">
                        <input id="serverIp" asp-for="User.UserName" readonly type="text" class="form-control" style=" margin-left:10px;font-size:15px;font-family: 'Open Sans' , sans-serif;font-weight: bold;" maxlength="30" />
                    </div>
                </div>*@
             
                <p><strong>Company:</strong> @TempData["Company"]</p>
                <p><strong>Branch:</strong> @TempData["Branch"]</p>
                <p><strong>Env:</strong> @TempData["Environment"]</p>*@
     

            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
                <button type="submit" class="btn btn-primary" id="save-btn">Save changes</button>
            </div>
        </div>
    </div>
</div>
@if (ViewData["SearchResults"] != null)
        {
<table>
    <thead>
        <tr>
          
                <th style="display:none;">ID</th>
            <th>BranchType</th>

            <th>UserPC</th>
            <th>PrinterName</th>
            <th>ArabicConfig</th>
            <th>Status</th>

            <th>Location Name</th>
             <th>>Action</th>
        </tr>
    </thead>
    <tbody>
        
        @foreach (DataRow row in table.Rows)
        {
            <tr>
             

                <td style="display:none;">>@row["AutoID"]</td>
                <td>@row["BranchType"]</td>

                <td>@row["UserPC"]</td>

                 <td>@row["PrinterName"]</td>
                <td>@row["ArabicConfig"]</td>
                <td>@row["Status"]</td>



                <td>@row["DisplayName"]</td>
                    
                <td>
                        <button id="editshiftlabel" data-bs-toggle="modal" data-bs-target="#editshelflabelModal" class="btn btn-primary" data-id="@row["AutoID"]" data.Location="@row["DisplayName"]" data.printername="@row["PrinterName"]" data.serverip="@row["UserPC"]">Edit</button>
             
             </td>  
            </tr>
        }
    </tbody>
</table>
        }
        else
        {
<p>@Model.errormsg</p>
        }
@section scripts {

    <script type="text/javascript">

        $(document).ready(function(){
            
               $('#editshiftlabel').click(function () {
                 console.log("success edit")
                var id = $(this).data('ShiftId');
                console.log(id);
                var serverIP = $(this).data('serverip');

                var printername = $(this).data('printername');
                var location = $(this).data('Location');
            
                $('#edit-id').val(id);
                $('#edit-ip').val(serverIP);
                $('#edit-printername').val(printername);
                $('#edit-Location').val(location);
                $('#editshelflabelModal').modal('show');
               
            });

 


Answers (4)