how do I store data into database using javascript - javascript

I am using Google Map API to do address translation(mainly by geocoder).
And I'd like to store results into local database for future use since google map has a limit on total query number and frequency.
But how? I have googled and found an ActiveX based solution. Is there platform independent alternatives?

To access a database you are going to need a server side language. JavaScript can talk to PHP through AJAX and PHP can update the database with whatever parameters you give to it via JavaScript.
I would stay away from ActiveX as it can be tricky and you just dont need it.
When you have a database setup, have a look at these websites
http://www.tizag.com/mysqlTutorial/mysqlinsert.php
http://api.jquery.com/jQuery.ajax/

Current in-browser database options include IndexedDB, Web SQL, and Web Storage.
Browser support, however, isn't all that good. Web Storage is your best bet, but it won't work on IE7 and earlier.

Related

Javascript Outlook GAL

Is there any way to pull data from something like a global address list in outlook through javascript(not locally)? An example would be to be able to search for a contact and then taking their data from the server to be stored to local variables.
Not locally indeed. The web browser itself has no access to this information without some sort of plugin.
What you want is an ajax call to a web server in your domain that delivers this list in json. It's up to the platform you are using to list the people in your address list.
It's possible to use the global address list (read this) but you probably just want to search your LDAP database.
But all of this is usually done in either ASP/C# or PHP. You can find plenty of examples to do so.

how to connect Website to MYSQL database?

Am currently working on a website(html 5) that calculate the expenses for the user, after the calculation, user has to save it as report for future purposes. So i wanna know if there is anyway to connect the website to MYSQL database or any alternative way rather than create database using java script because am a novice on Js.
thankyou
ideally you should be writing some server side code to add this sort of information to a database. that way you can secure access to authorised users (i.e. logged in users) and your queries cannot be modified on the browser by any user. you can use a programming language like PHP (with a framework like Yii, CodeIgniter) which is quite lightweight.
Browsers have no built in mechanisms for connecting to a MySQL server.
Your options are:
Write a browser plugin
Write a web service and use JavaScript to create an XMLHttpRequest object to communicate with it
The second option is the most common one (and almost certainly the best since it doesn't require that the user install a browser plugin or that you give direct access to the database to all your users).
If you want to use JavaScript, then you can create your web service with (for example) Node.js and the mysql driver in npm.
You should use HTML5 Web SQL for this purpose. Here is link you can refer to:
http://www.tutorialspoint.com/html5/html5_web_sql.htm

Saving user's previous search queries

How can I do that?
To start with, planning to save it into the HTML5 local database using IndexedDB? May be later on I can save it the user's table in the database.
Is this the right approach?
if they will be using the search on multiple devices save it on the server side. that way they get their complete search history. if not go with local.
do not forget to have a mechanism to purge the search queries on a user action.
Indexeddb is not design for that kind of usage. It is better of with usual http caching.
Indexeddb is design for storing full table and query client side itself.

Any way to save HTML Form data to database without webserver/sql?

So currently i'm buidling a local website within work.
one of the feature that needs to be built is a request submission form.
We originally had this email to a central mailbox but we want it to take the form data and save it to a database in this case Access.
Is there any possible way of doing this without using SQL or ASP ? As the website is being build on a local server for all members of staff to access.
In the end all I want to do is create a form the user can submit which is sent to a database. Is it possible or would it be better to stick with the email idea?
It is not possible to save data without a database server. Only thing can be done is cookies in javascript but these will not be available always and will never help you cause..
First of all I would like to say that html/css is client side scripting language, without using server side language you can't save anything. You can use php or javascript(ajax) in order to do that.
Unless you are targeting Safari browsers, you can try using IndexedDB(http://caniuse.com/#feat=indexeddb), a form of local storage supported by major browsers, with no size limit. It can be used carefully to emulate a remote database using a JavaScript object relational mapper.
I strongly suggest you a server :). If you don't want to use sql there are many ways to save data. The simplest would be to write a file on disk with what you need.
Only under Internet Explorer, you can save data into MS Access database for example using ActiveX. But html file must be open locally.
Edit:
If needed I can write you a sample code.

Collecting data locally on the iPad for retrieval later

This isn't a native iPad app. This is a HTML5 web app which runs from the iPad's local storage (so it will display offline).
What I need to do is have a form which collects information and stores it somewhere locally for retrieval later.
Is there any way I can achieve this. I don't care how the data is stored, just that it doesn't expire (like cookies do) and its relatively easy to retrieve at a later date.
Thanks
Apple have a Safari Client-Side Storage and Offline Applications Programming Guide section in their documentation. It lists the various options.
Key-Value storage sounds like it best fits your usecase.
If you don't care what you use, you can just as easily use cookies and set their expiration date to the year 3000 or something!
Alternatively you can take advantage of localStorage and store the form data in JSON format.

Categories