PDA

View Full Version : From the deepest pit of Newbie-ism.



Chronos
09-01-2004, 07:17 PM
I just started learning javascript and I got a good idea for a funny joke :cool:, it's the most "accurate" totaly random weather predictor. Yet for some reason I can't get it to stink'n work :confused: ... :eek:AHH!:eek: ...Anyway I need some help. I attached the code. Any ideas why it's not working? As soon as someone who knows javascript looks at this, they're probaly going to think "What an idiot! The problem is so simple!", well, I'm a newbie, if you know what the means. I've tried outsourcing the "function predict()" and ran it fine using cscript, so I don't think that particular thing has a problem, though I can't check all of it because cmd doesn't recognise "document.write()".

Ps Some people told me to put those backslashes there.

cr3ative
09-02-2004, 04:47 PM
Hi,

I think you've got your languages very confused!
Javascript isn't cscript, and the command prompt (cmd) doesn't recognise javascript at all! Still, no worries, its nice to see someone trying to make their own scripts. ;)

Also, don't leave your email address in scripts, it'll get harvested and spammed by computers designed to do so. Use this syntax instead: chronos0 [at] softhome [dot] net

Here's one I made earlier; use this script instead...
I might be nice to you and recreate your weather generator later ;)

Edit: Because I'm so nice :):), your finished script is attached on the post below this one.





<body>

<script language="javascript">

function random_text()
{};
var random_text = new random_text();
// Leave as 0.
var number = 0;
random_text[number++] = "Text 1"
random_text[number++] = "Text 2"
random_text[number++] = "Text 3"
random_text[number++] = "Text 4"
random_text[number++] = "Text 5"
random_text[number++] = "Text 6"
random_text[number++] = "Text 7"
random_text[number++] = "Text 8"
random_text[number++] = "Text 9"
random_text[number++] = "Text 10"
// Add more as necessary
var random_number = Math.floor(Math.random() * number);
document.write(random_text[random_number]);
</script>
<br><br>
Click <a href="javascript:history.go(0);">refresh</a> to see more random text.
</body>



Just replace the text and you're laughing.

Hope this helps!
cr3ative

cr3ative
09-02-2004, 05:34 PM
After much tweaking and poking, here is your weather generator, fully based on your ideas.

Let us know when you have your website running!

Chronos
09-02-2004, 09:58 PM
Thank you very much, I don't know why it didn't work, It only showed HTML I put in the <body> before the script, I tried switch and if's using just plain math.random(), <'s, and >'s... Anyway, I'm pretty sure cscript can understand, because if you try to enter a file with an unknown file extension it has an error, <file>.js didn't get this, and it even listed an error I didn't notice. It doesn't, however, understand commands like document.<blablabla>, being cmd.