how to save changes on website with textbox - javascript

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.

Related

How to apply password prompt javascript on acrobat pdf

I have a pdf which needs a javascript prompt that would asks for a username and password or just one of these. I have tried the native javascript way inside the javascript editor of acrobat. Alerts work fine but prompts are not working for me.
var customerName = prompt("Please enter your name", "");
have also tried
var customerName = app.prompt("Please enter your name", "");
EDIT:
WEll i tried to remove the complex parts of the process so that you guys can understand better. but i guess i owe you guys some explanation on what i am trying to achieve.
Well i have an empty pdf which i am going to send to my users and when it is opened it will ask for a username/password which is then submitted to my website through an api. I already have an api in place which would check for the correct credentials and on success would print the desired pdf content on a php page, which could be grabbed as a curl request through the javascript inside the empty pdf. And when i want to revoke the access to the user i would just delete the user from the database on my server. So the next time he wants to read the pdf he wont be able to pass through the api security.
Well i know there are some drawbacks on applying so many restrictions like pdf reader compatibility etc. but even if it only works on acrobat that would be fine. Later on will try to remove the print and save options etc.
Most of the parts are done the only thing i am stuck at the moment is on how to send a form GET request to a url. I think js prompt doesn't work in acrobat so i guess i have to send the data through an acrobat form. Any one knows how can i send a get request through the forms or get the values of input boxes in javascript?
Thank you everyone, i just found out on how to post data to a webpage. Here is the link,
Can a PDF fillable form post itself to an HTTPS URL?
Instead of choosing "PDF the complete document" from the format options, choose html.

Trying to save Multi-Value Form on server for users to call up during another session

been searching here for a while on how to save form information to be re-called later.
Here is my site: http://d3barb.com
The purpose is people fill out the 100+ fields in the form and it will generate numbers corresponding to the game Diablo 3. The formulas all work perfectly, and sometimes the cookie will save the information, but I'm trying to figure out a way to save the entire "page", so users can call them up during a different session.
I've tried for about 6 hours to get setCookie / getCookie functiond to create a cookie with all the values saved, but can't seem to get it to work. Even if it was working, it would only allow the user to load their last seission when re-visiting the site.
How I would like it perform:
1.) User inputs information for the form to calculate.
2.) User fills out a "name" text field and hits a "Save" button (I have these on my test page, but don't want it live until its working), which will save the values on my server containing all the form information as they've entered it.
3.) The next time that User visits the page, they would hit "Load" to call up a previous session.
I'd like to avoid user-account log-ins, so if possible I'd like the server to save the sessions by IP address & user submitted session name, something like: 142.105.103.125.fire crusader
Currently, the page is html with js calculating everything. I can convert it php for server interaction, but if there is another way, I'm all ears.
I'm not looking for handouts, so any links to tutorials would be greatly appreciated. If someone has done something similar to this and wouldn't mind sharing that page or code with me, I can do my best to frankenstein it for my page. (pretty much how I do all my websites haha!)
Have you tried/considered HTML 5 local storage?
http://www.sitepoint.com/html5-web-storage/
should get you started :)

How can I make a search box to search in a local database?

I'm playing around with Apache Cordova and I want to implement a search box that can search in a list or something similar (local database?). I want it to be local so that the app does not require an internet connection to search.
The way I want it to be set up is that it need to be able to search for both the name of the item and a number.
Example 1:
A user searches for: "Honda". He will then be sent to a page where information about "Honda" will be diplayed.
Example 2:
A user searches for the id: "1337". He will then be sent to the page containing information about "Honda".
So "Honda = 1337" and "1337 = Honda" if you guys understand?
The question:
I'm wondering what solution would suite my needs for this project?
or there any frameworks out there for this?
Thanks in advance!
It depends on what you want to have the search box and submit to be like.
One way is to use this really great tool http://ivaynberg.github.io/select2/ it can load data from database (using either ajax or load all of your data and only filter them) and shows them in selectbox. You can have submit button or something like that next to your selectbox.
Other way might be to use http://www.datatables.net/ it has search box, which can load data to table using ajax where you can have additional information and submit button for sending user to specific page.
There is plenty of other tools for this kind of problem, I used these two and I can say

Use Python to return data from a Webpage's Ajax call

I'm writing a program in Python that needs to use a site's advanced search options. Specifically, the search page is the NVC advanced search page . I know the names of the projects and versions I need to search for, so ideally the program would select the project names and versions numbers from the dropdown lists, then return the results page(s).
I'm totally unfamiliar with HTML and Javascript, and I'm fairly new to Python, so I don't know if there's a way to 'click' these dropdown menus via Python, then return the results. The fact that the Javascript makes an Ajax call further complicates the situation, since I can't just load the page's source and parse out the list of project names and version.
Can anyone with some Python/Javascript/Ajax experience send me in the right direction?
An example use of this program would be that I start out with the project "glibc' and its version number '2.3.6' The program would make sure that this combination is listed at all (which isn't guaranteed), then return the results page (which has about 13 results).
The Mechanize Python library is perfect for form automation. There is an example of how to edit and submit forms on the examples page.
If a human user is using that search page, they click on one of the product links, which then load the list of products from another page, e.g.:
http://web.nvd.nist.gov/view/vuln/cpe/cpe-chooser?index=0&component=Vendor
This page is unfortunately not using JSON, so they have some custom javascript parsing for the response. The data from this response is then displayed as a drop-down for the user. When the user selects a product, the browser selects the correct value, so that when the form is submitted, it will be part of the query. e.g.:
http://web.nvd.nist.gov/view/vuln/search-results?adv_search=true&cves=on&cpe_vendor=cpe%3A%2F%3Aa-a-s_application_access_server
In this, cpe_vendor=cpe%3A%2F%3Aa-a-s_application_access_server is the important part. The part before the = sign is the field name, the part after is the selected value (which originally came from the ajax request). The funny %3A bits are URL-encoding.
So you don't actually need to interact with the page, since you know the names of the vendors and products for which you want to search; you just need to look up the field name (cpe_vendor for vendors) and the value for the specific products/vendors (cpe:/:a-a-s_application_access_server for my example above), then do a request to the normal search URL.
The advanced search options page sends the options via GET to the results page, giving you the URL (linebreaks mine to make it clearer):
http://web.nvd.nist.gov/view/vuln/search-results?
adv_search=true&
cves=on&
cve_id=&
query=&
cwe_id=&
cpe_vendor=cpe%3A%2F%3Aian_bezanson&
cpe_product=cpe%3A%2Fa%3Aian_bezanson%3Adropbox&
cpe_version=cpe%3A%2Fa%3Aian_bezanson%3Adropbox%3A0.0.3_beta&
pub_date_start_month=0&
pub_date_start_year=2005&
pub_date_end_month=2&
pub_date_end_year=2009&
mod_date_start_month=2&
mod_date_start_year=2007&
mod_date_end_month=9&
mod_date_end_year=2009&
cvss_sev_base=&cvss_av=&
cvss_ac=&
cvss_au=&
cvss_c=&
cvss_i=&
cvss_a=
It would then take a bit of sleuthing to figure out what bit of the url is what information from the form but that should let you then just scrape the results page.

Export JSP output to a PDF on click of a button

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.

Categories

Resources