locked
how can I print hidden input value to a paragraph tag RRS feed

  • Question

  • User-1355965324 posted

    I am trying to print the value of  hidden input  value to a paragraph. Here is my code. Sorry for asking basic question

     <div class="modal-header">
                        <input type="hidden" id="lblID" />
                        <input type="hidden" id="lblfilename" /> // the value is displayed here
                        
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">Confirm Delete</h4>
                    </div>
                    <div class="modal-body">
                        <p>Are you sure to delete the file?  < lblfilename >   </p> 
                       
                    </div> // I want to show the lblfilename inside the  <> in p tag 
    
    
     function ShowDeleteModalPopup(id, filename) {
            $('#lblID').val(id);
            $('#lblfilename').val(filename);
            $('#deleteConfirmationModal').modal('show');
            
        }

    Saturday, February 22, 2020 8:34 AM

All replies

  • User475983607 posted

    Don't make up your own imaginary techniques just use the standard HTML..

    <p>Are you sure to delete the file?  <span id="filename"><span>   </p> 
    $('#filename).html(filename);

    Saturday, February 22, 2020 12:22 PM
  • User1535942433 posted

    Hi polachan,

    Accroding to your description and codes,I suggest you could get the value and append the value to the p tag.

    More details,you could refer to below codes:

     <script>
            $(function () {
                $("#Button1").on('click', function () {
                    event.preventDefault();
                    var value = $("#lblfilename").val();
                    $("p").append(value);
                    $("#myModal").modal('show');
                })
            })
        </script> 
    
    
    
    <asp:Button ID="Button1" runat="server" Text="Button" />
            <!-- Modal -->
            <div id="myModal" class="modal fade" role="dialog" style="display:none">
                <div class="modal-dialog">
                    <!-- Modal content-->
                    <div class="modal-content">
                        <div class="modal-header">
                            <input type="hidden" id="lblID" />
                            <input type="hidden" id="lblfilename" value="1111"/>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                            <h4 class="modal-title">Confirm Delete</h4>
                        </div>
                        <div class="modal-body">
                            <p>Are you sure to delete the file?</p> 
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        </div>
                    </div>
    
                </div>
            </div>

    Result:

    Best regards,

    Yijing Sun

    Monday, February 24, 2020 7:11 AM