Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML Source with JQuery or JavaScript after edit

Im using this to capture the HTML source for a single html page. It works good except for one thing. After entering values into my html page, when I do the capture it only captures the page without the edited values.

Any Ideas please.

var getDocTypeAsString = function () {
    var node = document.doctype;
    return node ? "<!DOCTYPE "
    + node.name
    + (node.publicId ? ' PUBLIC "' + node.publicId + '"' : '')
    + (!node.publicId && node.systemId ? ' SYSTEM' : '')
    + (node.systemId ? ' "' + node.systemId + '"' : '')
    + '>\n' : '';
};




 function getPageHTML() {
     //    alert( "<html>" + $("html").html() + "</html>" );

     console.log(getDocTypeAsString() + document.documentElement.outerHTML);    
 }

and the call from the button

<div class="no-print">
    <div class="buttonBar">
        <input type="button" class="button" value="Print" onClick="window.print()">
        <input type="button" class="button" value="Save" onClick="getPageHTML()">
    </div>
</div>

The editing values will come from similar fields like this So I would like to capture the edited 'PastMedicalHistory' as-well

<div class='row'>
    <div class='cell100'>
        <div class='table'>
            <div class='cell100 content'>
                <textarea id='PMH' class='basicTextArea PMHText' name="PastMedicalHistory"></textarea>
            </div>
        </div>
    </div>
</div>
like image 961
morne Avatar asked Jun 25 '26 13:06

morne


1 Answers

What are you trying to achieve?

The statement document.documentElement.outerHTML will take the HTML itself as rendered.

The values of the input elements are filled in afterwards, so not visible via outerHTML.

You could run through the elements, inspect them and populate the DOM.

What would be for the best, though is to describe what are you trying to achieve and put the full code example on codepen or similar.

like image 133
Bojan Bjelic Avatar answered Jun 28 '26 03:06

Bojan Bjelic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!