Jeditable displays entire HTML document as replacement for the editable field after trigger/submit - jeditable

I am using jeditable and had it working very weird.
after editing the editable field and submits it instead of printing the new content it displays the entire document window in the textbox(placeholder of editable content).
question: from the example where the author used save.php. what was the content of save.php?
is it necessary to send the result on a php file?? can't an HTML file work?

I believe within the comments box at the bottom of the author's main page - somebody has kindly provided a version of the save.php file for people to use and modify as needed.
The save.php file is used to actually save the values of the editable field/s. Without it, nothing would happen to the data and it would reset to the default text if the page is refreshed.
Options instead of a php file could be:
Saving the text/select changes to a Cookie
Using another server side methos such as asp, jsp, rails or .NET to process the saving of the changes.
an html page is a static page with no processing facility per say to communicate with the website server, so no.. html is not suitable for such a need.

Saving script must return the string you want to display on page after editing. You are now returning full html page.
Source of for all demofiles can be found from GitHub.

Related

TinyMCE / Prestashop - get HTML content

I'm currently working on a website and I have to use Prestashop.
I created a back office interface that allows the user to write, edit and delete articles. So I put a tinyMCE editor in it.
The problem is that when I click on 'save' to store the article in the database, it only stores raw text, without the styling content (html tags, bold text etc)
I would like to know how to get the whole content, including html tags, styling etc.
Thank you.
Ok so all I had to do was to change self::TYPE_STRING to self::TYPE_HTML in my Article.php file.

How can I render a completed CGI form as a PDF?

I have an HTML form which a user may have filled in or partially filled in. I want to snapshot that state and render it as a PDF document. I've been using wkhtmltopdf.
I've tried this from both the client side and the server side, and the rendered result is always the original form, never the filled-in one.
I notice if I reload the filled-in form page I get back the filled-in form, but if I cut and paste the form's URL into a new window, I get the initial, non-filled-in form.
So I've convinced myself that, if I could use CGI::Session properly, I could successfully open a session identical to the filled-in session. I tried using CGI::Session::Plugin::Redirect with no joy. I think the key is that window.open() has to use the SID of the filled-in form window.
I don't have a lot of experience with CGI session management, so this has been a four-day quest to nowhere. Any advice is appreciated, even if it's to abandon this approach and go back to the more common post->render a new form in a new window, and generate the PDF from that. I'd like to avoid all of that if I can.
Say you have the following HTML document on your web server:
/var/www/html/index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<form action="/process.cgi">
<input type="text" name="foo">
</form>
</body>
</html>
When you navigate to http://hostname/index.html in your browser, the webserver returns this document and the browser displays it.
When you fill in the text field in your browser, the document on the webserver doesn't change. So anybody who navigates to http://hostname/index.html will get the original, unmodified form. This is why you can't simply copy and paste the URL into another browser tab and get the filled-in form.
Most browsers use caching by default. When you fill in some fields in a form, the browser caches what you entered. When you reload the page, the webserver sends the exact same document as before* (i.e. the unmodified form), but the browser uses the cached data to fill in the form fields the way you had them. If you override the cache when you reload the page (Ctrl+F5 in Firefox), the form fields will not be filled in. Note that neither the URL nor the document on the server have changed. This is why you can't copy and paste the URL into another browser tab after reloading the page and get the filled-in form.
wkhtmltopdf takes a URL, renders the corresponding page, and generates a PDF based on what is rendered. Based on the explanation above, it should now be clear why wkhtmltopdf always generates an image of the unmodified form.
The solution
If filling in form fields doesn't change anything on the webserver, what does it change? It changes the DOM, a structure describing the document in your browser that you can access using JavaScript.
One approach would be to use a client-side JavaScript PDF generator like jsPDF; since it runs on the client, it has access to the DOM that the user is interacting with, so it can "see" the values the user enters into the form fields.
* Actually, the webserver will typically send a 304 Unmodified response to save bandwidth, but form caching works the same either way.
The explanation from ThisSuitIsBlackNot is accurate about why your design is failing. Typing characters into form fields in a browser changes only your screen and the data in the memory allocated to the browser.
I suggest a different solution. The WWW::Mechanize::Firefox module is a variant of WWW::Mechanize that uses a real browser application to retrieve and render web pages. It is mostly chosen when a site requires JavaScript support, but it is useful here because it has a content_as_png method which returns a PNG image of the current page. Hopefully that is enough for you to build a PDF file with the required content

Blue Imps jQuery file upload send files with form like normal field

Is it possible to send file with form as normal file upload? When I check a file field it is always empty, and I need to send it with form data in one call. IS that possible?
There might be better answers out there, but I ended up solving this by following steps.
Having 2 forms on the page. One for file upload and one for other form data.
Format both forms using CSS so that user gets look and feel of one form.
Have only one div (which looks like button) to submit. Hide the actual form's submit button, if you are using them (I don't. Because I preprocess data and then send by ajax)
Once user submits forms (by clicking the dummy button), Using JS programatically click the file upload button.
Optional Once that call is finished, if there are no errors only then continue.
Submit the form with other form data.
The advantage I had in this approach was that I could have more control over user's form data as well as my file upload's settings. Because I had some settings (like max number of files and max file size) were dependent on user's form entry.

Open generated PDF in new tab / window in perl

Please help. I want to open generated PDF in new window / Tab in perl.
User needs to fill the form like First Name,Last Name, Email in web page. The form contents will be filled in PDF using PDF generator. The PDF will be generate dynamically.
In my case,
There is no issue with PDF generation. The generated PDF opens in the same window. This should be open in new tab/ window.
I have tried with "_blank" in form level. The form have certain validations. So it's opening
in new tab when the form have validation errors.
The below the content type which i have used in the pdf page.
content_type : application/pdf
Content-Disposition : inline
If you set the target attribute of a HTML <form> element, the page resulting from the form submission will always displayed using that target. Having a form which either returns a HTML page on invalid input or a PDF is generally a bad idea.
IMO the following is a better solution also from a usability standpoint:
Don't set a target on your form.
If the form is submitted successfully, return a new HTML page in the same window.
Create a link or a form with hidden inputs on that page that contain the parameters entered before.
Name the link something like "Open PDF".
Point the link to your script which actually creates the PDF.
Make the link open in a new window.
Alternatively, you could implement a JavaScript-based solution, possibly using AJAX.

How would I display posts from an asp file in the DOM?

I'm creating a website where users submit text field entries and they are publicly displayed. I have the Javascript to submit the entry and post to a file on our servers ready. But, how do you take posts using the javascript "get" method and display them in the DOM? To clarify I'm taking text and picture entries from an asp file and display 10 of them in the DOM (empty divs in the HTML).
Usually you save the submissions in a database, not files. Then query the same database to pull them back out. You can then fetch them in a page reload or use AJAX to load them into the current page.