views:

68

answers:

2

Hello guys, i am making some script for some personal use. Now i tend to keep my CD collection list in a html file which has some sleek design, but i am tired of editing the list by "hand" and that means that i don't want to edit the code everytime i add new CD. So is there a way that i can use JS or JQuery so i could add/read from a local file(this script is not remote it is local(although i might try to host it remote).

I don't want to use any other language than HTML, CSS and JS/JQuery.

EDIT: Is it possible to add a link that when i click some application on my computer would launch.

+1  A: 

Not if you only want to use HTML and javascript. You will need a server side script of some kind to write to a file.

The comments got me thinking, I know this is not really what you were asking but you could play around with server side javascript with node.js

HurnsMobile
While not yet fully supported, this should be possible using HTML5's local storage.
Jamie Wong
@Jamie Wong that came to my mind as well.
mhitza
Using current technology my answer stands...
HurnsMobile
but the script will be on my computer so my pc will be server and client in same time. I think it should be possible somehow.. :D
dimitar
Why? JavaScript is sandboxed so it can't touch the local machine (except through certain very limited channels). A web server running locally is just another web server accessed over the network (even if it is the loopback interface) as far as JS is concerned.
David Dorward
Even though the script is on your computer, its executed by an engine running in browser.
Tushar Tarkas
A: 

You can do it like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd"&gt;

<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>CD Collection</title>
    <script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
    <script type="text/javascript" charset="utf-8">
        var cds = ['cd1', 'cd2', 'cd3'];
        $(function() {
            $(cds).each(function() {
                $('#cd_list').append('<li>' + this + '</li>')
            });
        });
    </script>
</head>
<body>
    <p>
        <ul id="cd_list"></ul>
    </p>
</body>
</html>

The inline js with the cd list can be loaded in as a separate file in the same way jquery was pulled in.

Matt Williamson