Reading a text file in JS
-
Is it possible to read a text file in javascript? Sample code pls..
-
Is it possible to read a text file in javascript? Sample code pls..
Since google seems too hard to use for you I found you some links with relevant information. Now all I can wish for is that you'll study them carefully.
Have fun! Regards,
— Manfred
"I had the right to remain silent, but I didn't have the ability!"
Ron White, Comedian
-
Is it possible to read a text file in javascript? Sample code pls..
No. not generally easy from within a web browser. It's a security risk. But you can disguise file as .js and load it with the script tag. <script language="javascript" src="file.js"></script> The file *must* contain valid script code. But you can put your data in string form, assigned to a variable. Note: the external file must not contain any script tags. direct loading of any file type is possible when using the following.. Web servers node.js spidermonkey shell rhino shell Windows Script Host (cscript)
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan That's what machines are for. Got a problem? Sleep on it.
-
No. not generally easy from within a web browser. It's a security risk. But you can disguise file as .js and load it with the script tag. <script language="javascript" src="file.js"></script> The file *must* contain valid script code. But you can put your data in string form, assigned to a variable. Note: the external file must not contain any script tags. direct loading of any file type is possible when using the following.. Web servers node.js spidermonkey shell rhino shell Windows Script Host (cscript)
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan That's what machines are for. Got a problem? Sleep on it.
It is good idea. I have to try it :)
-
It is good idea. I have to try it :)
here's an example. :) This is the external file, i have called it extern.js
this['data_array'] = [ "The quick brown fox jumped over the lazy dog.", 123, 456, "etc.." ];
this['data_json'] = { item1 : "the quick brown fox jumped over the lazy dog.",
item2 : 123, item3 : 456,
item4 : "etc.."
}Code for the web page that loads it.
<head>
<script type="text/javascript" src="extern.js"></script>
<script type="text/javascript">
function dw(s) { var s = s || ""; document.write(s + "
"); }var i = 0;
while (i < data_array.length) {
dw(data_array[i]);
i++;
}dw();
dw("item1. "+ data_json.item1);
dw("item2. "+ data_json.item2);
dw("item3. "+ data_json.item3);
dw("item4. "+ data_json.item4);</script>
</head>
<body>
</body>
</html>"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan That's what machines are for. Got a problem? Sleep on it.
-
here's an example. :) This is the external file, i have called it extern.js
this['data_array'] = [ "The quick brown fox jumped over the lazy dog.", 123, 456, "etc.." ];
this['data_json'] = { item1 : "the quick brown fox jumped over the lazy dog.",
item2 : 123, item3 : 456,
item4 : "etc.."
}Code for the web page that loads it.
<head>
<script type="text/javascript" src="extern.js"></script>
<script type="text/javascript">
function dw(s) { var s = s || ""; document.write(s + "
"); }var i = 0;
while (i < data_array.length) {
dw(data_array[i]);
i++;
}dw();
dw("item1. "+ data_json.item1);
dw("item2. "+ data_json.item2);
dw("item3. "+ data_json.item3);
dw("item4. "+ data_json.item4);</script>
</head>
<body>
</body>
</html>"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan That's what machines are for. Got a problem? Sleep on it.
This is really great sample thx.
-
here's an example. :) This is the external file, i have called it extern.js
this['data_array'] = [ "The quick brown fox jumped over the lazy dog.", 123, 456, "etc.." ];
this['data_json'] = { item1 : "the quick brown fox jumped over the lazy dog.",
item2 : 123, item3 : 456,
item4 : "etc.."
}Code for the web page that loads it.
<head>
<script type="text/javascript" src="extern.js"></script>
<script type="text/javascript">
function dw(s) { var s = s || ""; document.write(s + "
"); }var i = 0;
while (i < data_array.length) {
dw(data_array[i]);
i++;
}dw();
dw("item1. "+ data_json.item1);
dw("item2. "+ data_json.item2);
dw("item3. "+ data_json.item3);
dw("item4. "+ data_json.item4);</script>
</head>
<body>
</body>
</html>"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan That's what machines are for. Got a problem? Sleep on it.
In actually I'm woking on the lottery picker script .. I have job experience in the past for that bit of luck lotto combination now i want to make a scripting. I want to make the anatomy of the program combination lottery's anatomy is as follows: Lucky numbers in the last week and the previous week each one between and each other once the lucky lottery numbers, which will be played the week after the coupon is fixed or randomly selected from the remaining numbers in arithmetical or mathematical and two column of the week that determines the coupon. Weekly 6/49 lotto ----------------- x1,x2,x3,x4,x5,x6 - Previous week x1,x2,x3,x4,x5,x6 - Last Week Forexample: x2 and x4 numbers are lucky pick numbers that up to up for two weekly score. (-- random or arith. math reslt) 1. Column : --,x2,--,x4,--,-- 2. Column : --,x2,--,x4,--,-- At first, the program or script should find out the lucky numbers in two weekly score and finally take it to me to 2 cloumn result.
-
In actually I'm woking on the lottery picker script .. I have job experience in the past for that bit of luck lotto combination now i want to make a scripting. I want to make the anatomy of the program combination lottery's anatomy is as follows: Lucky numbers in the last week and the previous week each one between and each other once the lucky lottery numbers, which will be played the week after the coupon is fixed or randomly selected from the remaining numbers in arithmetical or mathematical and two column of the week that determines the coupon. Weekly 6/49 lotto ----------------- x1,x2,x3,x4,x5,x6 - Previous week x1,x2,x3,x4,x5,x6 - Last Week Forexample: x2 and x4 numbers are lucky pick numbers that up to up for two weekly score. (-- random or arith. math reslt) 1. Column : --,x2,--,x4,--,-- 2. Column : --,x2,--,x4,--,-- At first, the program or script should find out the lucky numbers in two weekly score and finally take it to me to 2 cloumn result.
Sorry, it is very hard to understand you. Please delete your message, and start with a new thread. Try and provide example code, or just the general flow done with comments on separate lines like below. It will help you figure out what order to do things, and should help you explain it better on Code Project.
// Select lucky number(s) from last week (current_week -1)
// Select lucky number(s) from previous week (current_week -2)
// do this, *IF* *ELSE*
// do that, *IF* *ELSE*
.
.
.Include *any* old code you have written that you are wanting to redo in javascript.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan That's what machines are for. Got a problem? Sleep on it.
-
Sorry, it is very hard to understand you. Please delete your message, and start with a new thread. Try and provide example code, or just the general flow done with comments on separate lines like below. It will help you figure out what order to do things, and should help you explain it better on Code Project.
// Select lucky number(s) from last week (current_week -1)
// Select lucky number(s) from previous week (current_week -2)
// do this, *IF* *ELSE*
// do that, *IF* *ELSE*
.
.
.Include *any* old code you have written that you are wanting to redo in javascript.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan That's what machines are for. Got a problem? Sleep on it.
There is no code in my explain. week1 array week2 array After comparison of all elements in the array of 12 elements, the numbers 1-2-3 came time to play the next week swings are fixed and others.
-
There is no code in my explain. week1 array week2 array After comparison of all elements in the array of 12 elements, the numbers 1-2-3 came time to play the next week swings are fixed and others.
Yes. but I have no idea how your lottery system works. Your explanation is almost impossible to understand without some more detail. Or some code. ;) I want to help you. Q1. how do you decide when the random lucky numbers are produced instead of using previous ones? Q2. Are the new lottery number + lucky numbers produced (automatically) based on current Date & Time? I've done similar stuff a very long time ago, written in BASIC.
"It's true that hard work never killed anyone. But I figure, why take the chance." - Ronald Reagan That's what machines are for. Got a problem? Sleep on it.