I have made a simple webpage with a Javascript backend. I want the user to be able to enter in a bunch of data in form fields, and then save the page. PDF, HTML, doesn't matter, I just want to be able to save the page WITH all of the user's data.
This has to be client side only, I don't want people to have to setup a server just to use it.
The browser's security mechanism does not allow you to create files barring cookies. So may want to google JavaScript cookies and how to use them.
Have two pages, on your first present the form and submit it to the second page using (keep the method get:
<form action="second_page.html" method="GET"> <!-- Other stuff --> </form>
GET will send data as a part of the URL to the second page.
On the second page parse the URL to get the variables set by the user, you can use something like this. Use DHTML/JavaScript to display the values thus fetched into the format you may wish.
Related
How can I show the information I got from the place where I entered the title and text on the announcement page?
repo:https://github.com/qswezy/spa1
We have added the form and we want to show it in the announcements
Forms usually have target page. So, this is the page that will receive your submitted data, usually in some type of POST array (if you submitted it as a post.) If this assumes JavaScript, you probably need to run an Express server to do this.
Im new at web developing.
I want something like:
A website, that everyone can enter. on the website u have 2 parts: one is filled with textbox so any user can write something in it and click button 'save comment'. He other side is filled with the execution of that button(it displays added text comment -but not just for a moment but that text is saved on that website). Simple as that...
Do i use java script?
Ive been looking for the answers but kinda didnt know how to ask gooogle bout that
scheme on that website:
----------------------/----------------
-textbox--------------/--constant text-
--add comment button--/--wrote by user-
----------------------/----------------
You have many possible ways to do that. One of the ways is to use html with jquery and send the result via web service (.asmx for instance) and save that result in a database (MSSQL for instance). So everytime you load the page you can get those saved results and display it on the relevant page. Another way is to use php with mysql or to use java...
If you don't want to use databases and server side code you can save the results in a cookie and then display those results in the page.
This is what I have:
User fills very long html form
User gets link to download different pdfs (this are fillable forms), links are generated using javascript
User clicks link, url is generated (with the data the user submitted before), data is processed in the form and fields are completed *this is done using javascript inside the form).
User get pdf back with fields completed.
The problem I'm running is that in some cases the data needed to send to the form is around 8000 characters, when IE only allows 2083 character in the url.
As requested by client, we need to do everything client side, that means no access to php, c#, java. Also I'm using Acrobat Pro X, to work with the pdfs.
Is there a way to submit a post request, process that request in the pdf, fill the form and return the filled form to the user? Is there another way to go around the 2083 character limit of IE?
Why do you need to send 8000 characters of data to the server if you want to fill out the form on the client side? Seems like all you need to do is to establish communication between the JavaScript in the HTML page and the JavaScript in the PDF. This is explained here: PDF hostContainer callback
PS: I'm the author of the book from which this excerpt was taken: http://www.javabeat.net/2011/04/javascript-communication-between-html-and-pdf-in-itext/
I have a link, that when a user clicks on it, it loads a different page as normal but also executes a JS function that autofills a specific text-box on that different page. Is it better practice to use Jquery or Javascript to do this? How can I do this using either one of them?
You can't do this from the source page.
It's a security feature. Imagine if you wrote a JS function that went to an online banking page and auto-filled a bank transfer using the user's current cookie. That's why you can't.
If you control the other page then the sequence you can use is:
Save data to the server;
Go to the new page with a JS redirect;
The new page is loaded from the server;
While loading th epage the data that was saved from the server is retrieved and used to populate the text box.
So it can be done from the server but only if you save it there. The only way of doing that is using Ajax.
An alternative approach is:
Instead of a JS redirect, submit the page back to the server;
The server saves whatever data it needs to;
The server sends back an HTTP redirect to the new page;
The new page uses the saved data to construct the new page with the populated text box.
At the end of the script add return false;. This will make the page run the script without redirecting the page.
Edit: (after saw your edition).
Is it better practice to use Jquery or Javascript to do this? How can I do this using either one of them?
jQuery is a javascript library, this it doesn't matter if you use plain javascript or use jquery as long as you happy with the result.
And about what you say that you successfully manipulated a page fro the redirecter page... I don't see how it possible.
I have created a JSP with various fields. I want to provide an option to export the page to a PDF before submit but after the user fills in the form.
How can this be achieved? I am struggling with this problem past many days and not able to get solution.
You might want to look into the FlyingSaucer project. It's a mechanism for producing PDF files from XML documents, and in particular from a fairly strict XHTML doctype. It really works quite well, and it supports some CSS3 features for doing things like page headings, intra-document bookmarks (like links), and is generally pretty well-behaved about CSS rules. I don't think it does forms, but you could probably fake that if it's going to end up as a non-interactive document anyway.
Link: http://code.google.com/p/flying-saucer//
(If it's not clear, this'd be a server-side solution. The form would have to be posted, and your server would build the PDF and ship it back to the client.)
Or just use AJAX to submit the form. The use clicks "Generate PDF" or whatever and an AJAX post is made to send the form data to the server and return a generated PDF. That submit can go somewhere else than the service/servlet which is processing the form data.
Just use the Print option in Firefox 3.5. It has an option to print to PDF file. Alternatively, you can use PDFCreator or some other virtual printer software that writes to PDF file instead of printing on paper.
I want to provide an option to export the page to a PDF before submit but after the user fills in the form.
This is not possible at the server side as the information isn't submitted to the server side yet. Your only resort is the browser capabilities and the knowledge of the user how to use them.
If you can live with changing the flow to submitting into some result page and providing an link to export the current result page to a PDF file, then combine this answer with iText.
If you are trying to output a report you can look at display table: http://displaytag.sourceforge.net/1.2/. It comes with a simple servlet filter that will allow you to click a simple link and export to pdf, excel , etc.