Geekzone: technology news, blogs, forums
Guest
Welcome Guest.
You haven't logged in yet. If you don't have an account you can register now.


coolspidey

78 posts

Master Geek


#39391 13-Aug-2009 15:39
Send private message

Hi all,

I have this concept in my mind and I'd like some insights as to what is needed in order for this concept to work.

I envision a site that has some sort of interactive widget (for example, a calculator). Now let's say after the user hits the "Calculate" button, not only the widget would show the result immediately on the web browser, it would also update the result in the database on the backend.

Can a javascript do this? I understand that javascript is a client-only tool and as such has no capability to pass information to the server.

Or maybe instead of using a real database such as mySQL, I use a simple spreadsheet like Excel?

Can the script pass the information and update the spreadsheet as the user hits the button? I would imagine you can't do this since the spreadsheet still lies on the server.

So basically what I'd like to achieve is for this web application to update some file I have (either stored in the web server or my local hard drive) so I can keep track of the changes done by the user(s).

Any ideas?

Thanks heaps in advance :)

Create new topic
magu
Professional yak shaver
1599 posts

Uber Geek
+1 received by user: 7

Trusted
BitSignal
Lifetime subscriber

  #246078 13-Aug-2009 15:41
Send private message

The Javascript cannot pass the information directly to the database, but it can call an API of some sort (PHP script for example) that then inputs the information into the database (or updates a file on the server).




"Roads? Where we're going, we don't need roads." - Doc Emmet Brown



coolspidey

78 posts

Master Geek


  #246101 13-Aug-2009 15:54
Send private message

Hi thanks for the quick response.

So how would you go about doing this? I'm not very familiar with php. Would you be able to explain it a bit further if that's ok? (or post a tutorial link on this)

Thanks again.

magu
Professional yak shaver
1599 posts

Uber Geek
+1 received by user: 7

Trusted
BitSignal
Lifetime subscriber

  #246106 13-Aug-2009 15:59
Send private message

Your best bet is to try and find a good programming book (Google O'Reilly books for some good ones) and study those before attempting any code if you never touched programming before.




"Roads? Where we're going, we don't need roads." - Doc Emmet Brown



coolspidey

78 posts

Master Geek


  #246111 13-Aug-2009 16:02
Send private message

Fair enough. I have programmed before (mainly Java) and I have been exposed to php to a much lesser degree... but your answer helps. Thanks again :)

vectran
59 posts

Master Geek


  #246142 13-Aug-2009 17:03
Send private message

I think what you are after is AJAX (Asynchronous Javascript And Xml) - this is possible. Google Bing around for some tutorials.

Ilmarin
94 posts

Master Geek


  #246267 13-Aug-2009 20:38
Send private message

Take a look at DWR (Direct Web Remoting)... it's an easy to use AJAX framework for JavaScript and Java. You can download a webapp with examples. Obviously it helps if you're familiar with J2EE (servlet API) and JDBC for your database access.

http://directwebremoting.org/dwr/index.html

 
 
 
 

Shop now for Lego sets and other gifts (affiliate link).
coolspidey

78 posts

Master Geek


  #246325 13-Aug-2009 22:32
Send private message

Awesome, thanks heaps for your answers guys :)

casper021
96 posts

Master Geek


  #246437 14-Aug-2009 09:39
Send private message

Ajax --- whould be the best and the easyest way to go about it. If you have Microsoft Visual studio you can get and Ajax toolkit for it from asp.net




coolspidey

78 posts

Master Geek


  #246645 14-Aug-2009 15:57
Send private message

Yep you guys are right. I believe Ajax is what I need.

Thanks again guys :)

Ragnor
8279 posts

Uber Geek
+1 received by user: 585

Trusted

  #246702 14-Aug-2009 16:53
Send private message

Use a database imo, you will inevitably have concurrency problems if two people try and change the same file at the same time with a single file based approach.

The traditional way web apps are done is that you have an html form with input fields (texboxes, buttons etc) defined in your html page, the action of this form when you click the button does a http post to the server and the server does processing.

The ajaxy way is to handle the button click in javascript and prevent the default action of posting an html form to the server and instead call a webservice or page to do the processing asynchronously either by a http GET or http POST.

There are heaps of different ways to implement this :)


BenRees
27 posts

Geek


  #255318 13-Sep-2009 10:04
Send private message

Hey mate,
If you have previous experience in Java then maybe C# (Microsoft.Net) or Jsp would be a little more familiar to learn than PHP. Any entry level ASP.Net book will have examples on how to implement something straight-forward like this. Ragnor's advice is spot on, there are loads of free simple databases that are very easy to use in Visual Studio (MySql, Ms Sql-Express etc).

Hey if you're keen you could learn Silverlight instead of Asp.Net ;-)

Cheers
Ben

Create new topic








Geekzone Live »

Try automatic live updates from Geekzone directly in your browser, without refreshing the page, with Geekzone Live now.



Are you subscribed to our RSS feed? You can download the latest headlines and summaries from our stories directly to your computer or smartphone by using a feed reader.