#1
  1. Awake and listening...
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Berlicum, the Netherlands
    Posts
    127
    Rep Power
    14

    Red face


    I have a question:
    has anybody a clue if it is possible to make a javascript at my homepage that can orden e-mailadresses from a file alphabethicly?

    Note1: all e-mail adresses have a "," between them.
    Note2: I haven't worked with Java-script before, so code is welcome

    For instance:
    current file mail.txt:
    homer@junk.be, jerry@hotmail.com, al@freemail.com, etc@somethinglikethat.nl

    Becomes the file mail.txt:
    al@freemail.com, etc@somethinglikethat.nl, homer@junk.be, jerry@hotmail.com.

    The 4 main questions are:
    1. is it possible?
    2. how can I read in files?
    3. how can I put things alphabeticly?
    4. how can I get it back in the file?


    People who get a raise because of their good work have been underpayed for quite some time.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    USA
    Posts
    226
    Rep Power
    15
    I would put your e-mail addresses into a database. Query the database using ASP or PHP. You can output the addresses in any order with a SQL query command.
  4. #3
  5. Awake and listening...
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Berlicum, the Netherlands
    Posts
    127
    Rep Power
    14

    putting all in a database...


    I have thought of that of putting al those e-mail adresses in a database, but I wouldn't know how(it are quite a few) adresses). Do you know an easy way to put a text file into a database?
    People who get a raise because of their good work have been underpayed for quite some time.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    USA
    Posts
    226
    Rep Power
    15
    I know how to do it in Access. It is probably similar in other applications.

    All you have to do is go to file, get external data, and import. It is very simple.

    Good luck.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Montreal
    Posts
    31
    Rep Power
    14
    well js is for client side scripting how do you want to open a file using a client side scripting language when the file is on the server ? you can't except if you start using JScripting for the server side and that's another story.

    use a db with php/jsp/asp/cgi ...
    a db can be a flat file you don't really need access ...

    don't kill a fly with a nuclear bomb
    -patrick
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2001
    Posts
    1
    Rep Power
    0

    Lightbulb


    Javascript can't read or write to other files. It's completely client side.

    Here's the basic JS for what you want to do
    <script>
    mystring = 'homer@junk.be, jerry@hotmail.com, al@freemail.com, etc@somethinglikethat.nl';
    myArray = mystring.split(',');
    myArray = myArray.sort();
    for (i=0;i<myArray.length; i++){
    document.write(myArray[i]+'<br>');
    }
    </script>

    The thing is to read these files you need to do something to read from the server. You can use a server side include. where it would be something like this.

    mystring = '<!--#include virtual="/pathtotext/email.txt"-->'
    myArray = mystring.split(',');
    myArray = myArray.sort();
    for (i=0;i<myArray.length; i++){
    document.write(myArray[i]+'<br>');
    }

    That should work on most servers. The thing is to write to a new file you will need to use some sort of scripting language, perl, PHP etc. and if you have to use one of those anyway then you might as well do the whole shebang in that language instead of using JS at all.

    cheers
  12. #7
  13. Awake and listening...
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2001
    Location
    Berlicum, the Netherlands
    Posts
    127
    Rep Power
    14

    Thumbs up eh...filewriting



    Thanks all. I think I have something I wanted to see.
    I'll probably put it all in a textbox on the webpage, that shouldn't be to hard, I believe.

    People who get a raise because of their good work have been underpayed for quite some time.

IMN logo majestic logo threadwatch logo seochat tools logo