Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-29-2012, 11:35 AM   PM User | #1
donna1
New Coder

 
Join Date: Nov 2012
Location: london
Posts: 55
Thanks: 5
Thanked 1 Time in 1 Post
donna1 can only hope to improve
Smile html5 writing to database on server

Hello everyone,
I am new to this and have written a small html5 program to write a shopping list. I want to be able write my list on home or the work computer and view it from my phone or ipad later.
i have server space at 000web site and they have mysql and i have set up a table with three fields item number, product and quantity.

Is there any way html5 can read from and write to the database directly, or do I have to communicate with say a PHP server script to do that?

If i just had my shopping list stored as a text file on my server would I be able to read and write to it with html5 code directly

Thank you
donna1 is offline   Reply With Quote
Old 11-29-2012, 01:02 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,382
Thanks: 18
Thanked 350 Times in 349 Posts
sunfighter is on a distinguished road
No to both questions. If your working server side you need a server side language. Even reading a text file would require something like PHP.
sunfighter is offline   Reply With Quote
Users who have thanked sunfighter for this post:
donna1 (11-29-2012)
Old 11-29-2012, 06:19 PM   PM User | #3
donna1
New Coder

 
Join Date: Nov 2012
Location: london
Posts: 55
Thanks: 5
Thanked 1 Time in 1 Post
donna1 can only hope to improve
if I write a php server based script to load the shop list into an array will my html code be able to see it? What Im asking really is if variables can be global or do I have to pass the array back as a parameter to my html5 code (if that is even possible)

I dont know anything about ajax or jquery but I read something that made me wonder if either of those could read a text file on my server, if executed from javascript in the browser??
donna1 is offline   Reply With Quote
Old 11-29-2012, 09:23 PM   PM User | #4
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,382
Thanks: 18
Thanked 350 Times in 349 Posts
sunfighter is on a distinguished road
The php file will read your shopping list information and than generate the html page with that info embedded into it (normally as a table) that you will see in your browser. I will send you email, not today.
sunfighter is offline   Reply With Quote
Old 11-29-2012, 11:32 PM   PM User | #5
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,455
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
using javascript, you can save the info on the device, with the understanding that what's on your phone won't be the same as what's on your desktop at work...


if you want to store data centrally for many devices to use and share, you need a web server or some sort. this is not the same as a server-application. just webspace is enough to share with everyone.

you can do a half-way approach; cheap webhosting from someplace like godaddy will make text files show up at a url. you can upload these text files using ftp. once you do that, any device can READ the info using javascript.


if you want to save the info from any device, you'll need a server application.

you can use free server offerings like google spreadsheets's forms, or build a simple php relay to save the data on a server you control.

knowing your options, zoom in on what looks interesting to you and your available tools and skills, and ask here for more specific help.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me is offline   Reply With Quote
Old 11-30-2012, 10:17 AM   PM User | #6
donna1
New Coder

 
Join Date: Nov 2012
Location: london
Posts: 55
Thanks: 5
Thanked 1 Time in 1 Post
donna1 can only hope to improve
ok so if my shopping list is on a text file on my server what javascript command would read it from any browser?
Thanks
donna1 is offline   Reply With Quote
Old 11-30-2012, 11:51 AM   PM User | #7
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,036
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by donna1 View Post
ok so if my shopping list is on a text file on my server what javascript command would read it from any browser?
Thanks
Google for AJAX, or use the search feature of this forum
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote
Old 11-30-2012, 05:44 PM   PM User | #8
donna1
New Coder

 
Join Date: Nov 2012
Location: london
Posts: 55
Thanks: 5
Thanked 1 Time in 1 Post
donna1 can only hope to improve
Quote:
Originally Posted by Philip M View Post
Google for AJAX, or use the search feature of this forum
is there an unthank button on this forum?
Ive tried searching for for how to open server file in html5 but to no avail. until I know what the commands called its difficult to search for it.
donna1 is offline   Reply With Quote
Old 11-30-2012, 06:36 PM   PM User | #9
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,036
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Quote:
Originally Posted by donna1 View Post
is there an unthank button on this forum?
Ive tried searching for for how to open server file in html5 but to no avail. until I know what the commands called its difficult to search for it.
You are not trying.

http://robertnyman.com/2010/12/16/ut...ultiple-files/

Search for AJAX, or new XMLHttpRequest();
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.

Last edited by Philip M; 11-30-2012 at 06:39 PM..
Philip M is offline   Reply With Quote
Old 11-30-2012, 07:02 PM   PM User | #10
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,455
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
Quote:
Originally Posted by donna1 View Post
is there an unthank button on this forum?
Ive tried searching for for how to open server file in html5 but to no avail. until I know what the commands called its difficult to search for it.
i used this a lot the first few months i worked in javascript:

Code:
function IO(U) {
    var X =new XMLHttpRequest;
    X.open( 'GET', U, false);
    X.send();
  return X.responseText;
}

//usage:
var url=location.href;
alert(
  IO( url )
)
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me is offline   Reply With Quote
Users who have thanked rnd me for this post:
donna1 (11-30-2012)
Reply

Bookmarks

Tags
database, html5, server

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:23 PM.


Advertisement
Log in to turn off these ads.