+ 1

How can I send a inner HTML JavaScript dom via input type hidden to a PHP file?

?

27th Jan 2017, 10:54 AM
Claas Leo
Claas Leo - avatar
2 Answers
+ 2
Not a functionnal script, but for the principles: <div id="source">text content</div> <form submit="phpfile" method="post"> <input type="hidden" id="myhiddenfield"> <input type="submit" id="validbt"> </form> <script> var hid=document.getElementById('myhiddenfield'); var div=document.getElementById('source'); hid.value=div.innerHTML; </script> As is, you need the user submit the form, but you can trigger an event click by yourself: document.getElementById('validbt').click();
28th Jan 2017, 2:42 AM
visph
visph - avatar
- 1
Use script tag of html and embed all code at once
27th Jan 2017, 4:22 PM
Animesh
Animesh - avatar