Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Software Development
Programming
Programming Q&A
Convert html to Image and Download
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Shokkato" data-source="post: 475697" data-attributes="member: 79981"><p>I would like to convert every message that is received into an image, and with the download button download it. every post is different</p><p></p><p>This is what I get in html, each message should have its own download button</p><p>[MEDIA=imgur]Rrrn6lQ[/MEDIA]</p><p></p><p><strong>This is my .js code</strong></p><p>[CODE=javascript]// fetch Messages</p><p> function fetchData() {</p><p> $('#displayMessages').html('<div class="alert alert-info">We are looking for your messages!...</div>');</p><p> $('#messages').click();</p><p> $.ajax({</p><p> url: 'controller/fetch_comments.php',</p><p></p><p> //success</p><p> success: function(data){</p><p></p><p> if (data=='please login') {</p><p> window.location='./';</p><p> console.log(data);</p><p> }</p><p> else{</p><p></p><p> var $fetch ='';</p><p> var component ='';</p><p></p><p></p><p> </p><p> if (/^[\],:{}\s]*$/.test(data.replace(/\\["\\\/bfnrtu]/g, '@').</p><p>replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').</p><p>replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {</p><p> data=JSON.parse(data);</p><p> console.log(data);</p><p></p><p> $.each(data, function(i, fetchAll){</p><p> var fetchData= data[i];</p><p> let message_title = fetchData.message_title ?? ""</p><p> $fetch += '<div class="row m-0"> <div class="pull-left alert col-md-2 mb-0"><img src="assets/img/anon.jpg" style=" width: 50px; height: 50px; border-radius:50%; box-shadow: 0 3px 2px rgba(0, 0, 0, 0.3); border: 5px solid #2c2c2c;" class="m-0"></div> <div class="alert col-md-7 m-0" style="margin-left:0px; color:#2c2c2c;"> <b>' +message_title +'</b><br>' +fetchData.description</p><p> +'</div> <div class="col-md-3 alert pull-right m-0"><span style="color: black;" class="fa fa-clock m-0"></span><br><text style="color: black; font-size:10px;"> ';</p><p> $fetch+=fetchData.date_created+'</text></div></div>';</p><p></p><p> });</p><p></p><p> } else {</p><p></p><p> $fetch +='<div class="alert alert-danger">No messages yet.😒</div>';</p><p> console.log(fetch);</p><p> $('#displayMessages').html($fetch)</p><p> }</p><p></p><p> $('#displayMessages').html($fetch);</p><p> }</p><p></p><p> }</p><p></p><p> });</p><p></p><p>}[/CODE]</p><p></p><p><strong>this is the php code</strong></p><p></p><p>[CODE=php]$usersObj = new Comments();</p><p></p><p>$logsObj = new Logs();</p><p></p><p></p><p></p><p> $id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 1;</p><p></p><p> if (empty($id)) {</p><p></p><p> exit();</p><p></p><p> }</p><p></p><p></p><p></p><p> if ($allComments = $usersObj ->FETCH_COMMENTS($id)) {</p><p></p><p> $logDescription = 'data fetched!';</p><p></p><p> $logsObj->INSERT_LOG($id, $logDescription);</p><p></p><p></p><p></p><p> }else{</p><p></p><p> echo 'log failed';</p><p></p><p></p><p></p><p> }</p><p></p><p> echo isset($allComments) ? json_encode($allComments) : 'nothing found';$usersObj = new Comments();</p><p></p><p>$logsObj = new Logs();</p><p></p><p></p><p></p><p> $id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 1;</p><p></p><p> if (empty($id)) {</p><p></p><p> exit();</p><p></p><p> }</p><p></p><p></p><p></p><p> if ($allComments = $usersObj ->FETCH_COMMENTS($id)) {</p><p></p><p> $logDescription = 'data fetched!';</p><p></p><p> $logsObj->INSERT_LOG($id, $logDescription);</p><p></p><p></p><p></p><p> }else{</p><p></p><p> echo 'log failed';</p><p></p><p></p><p></p><p> }</p><p></p><p> echo isset($allComments) ? json_encode($allComments) : 'nothing found';[/CODE]</p><p></p><p><strong>This is my html in my dashboard, is used to show the message</strong></p><p></p><p>[CODE=html]<div class="tab-pane active" id="home" role="tabpanel"></p><p></p><p></p><p></p><p> <div id="displayMessages"></p><p> </div></p><p></p><p> </p><p></p><p></p><p> </div>[/CODE]</p><p></p><p>thanks to whoever can help me</p></blockquote><p></p>
[QUOTE="Shokkato, post: 475697, member: 79981"] I would like to convert every message that is received into an image, and with the download button download it. every post is different This is what I get in html, each message should have its own download button [MEDIA=imgur]Rrrn6lQ[/MEDIA] [B]This is my .js code[/B] [CODE=javascript]// fetch Messages function fetchData() { $('#displayMessages').html('<div class="alert alert-info">We are looking for your messages!...</div>'); $('#messages').click(); $.ajax({ url: 'controller/fetch_comments.php', //success success: function(data){ if (data=='please login') { window.location='./'; console.log(data); } else{ var $fetch =''; var component =''; if (/^[\],:{}\s]*$/.test(data.replace(/\\["\\\/bfnrtu]/g, '@'). replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { data=JSON.parse(data); console.log(data); $.each(data, function(i, fetchAll){ var fetchData= data[i]; let message_title = fetchData.message_title ?? "" $fetch += '<div class="row m-0"> <div class="pull-left alert col-md-2 mb-0"><img src="assets/img/anon.jpg" style=" width: 50px; height: 50px; border-radius:50%; box-shadow: 0 3px 2px rgba(0, 0, 0, 0.3); border: 5px solid #2c2c2c;" class="m-0"></div> <div class="alert col-md-7 m-0" style="margin-left:0px; color:#2c2c2c;"> <b>' +message_title +'</b><br>' +fetchData.description +'</div> <div class="col-md-3 alert pull-right m-0"><span style="color: black;" class="fa fa-clock m-0"></span><br><text style="color: black; font-size:10px;"> '; $fetch+=fetchData.date_created+'</text></div></div>'; }); } else { $fetch +='<div class="alert alert-danger">No messages yet.😒</div>'; console.log(fetch); $('#displayMessages').html($fetch) } $('#displayMessages').html($fetch); } } }); }[/CODE] [B]this is the php code[/B] [CODE=php]$usersObj = new Comments(); $logsObj = new Logs(); $id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 1; if (empty($id)) { exit(); } if ($allComments = $usersObj ->FETCH_COMMENTS($id)) { $logDescription = 'data fetched!'; $logsObj->INSERT_LOG($id, $logDescription); }else{ echo 'log failed'; } echo isset($allComments) ? json_encode($allComments) : 'nothing found';$usersObj = new Comments(); $logsObj = new Logs(); $id = isset($_SESSION['user_id']) ? $_SESSION['user_id'] : 1; if (empty($id)) { exit(); } if ($allComments = $usersObj ->FETCH_COMMENTS($id)) { $logDescription = 'data fetched!'; $logsObj->INSERT_LOG($id, $logDescription); }else{ echo 'log failed'; } echo isset($allComments) ? json_encode($allComments) : 'nothing found';[/CODE] [B]This is my html in my dashboard, is used to show the message[/B] [CODE=html]<div class="tab-pane active" id="home" role="tabpanel"> <div id="displayMessages"> </div> </div>[/CODE] thanks to whoever can help me [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Software Development
Programming
Programming Q&A
Convert html to Image and Download
Top