|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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
|
|||
|
|||
|
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.
|
|
#3
|
||||
|
||||
|
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?
|
|
#4
|
|||
|
|||
|
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. |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > javascript for orderening e-mail adresses |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|