Jump to content

Coding Help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 298 posts
Hello All,

I'm new to javascript so I decided to make a login page. (Kinda bad login page-I'm sure there is an easier way but still).

The code is:

<script type="text/javascript">

var choice=prompt ("Enter 1 if you need to sign up. Enter 2 if you 


need to sign in.");


if (var == 1)

{

var firstName=prompt ("What is your First Name?");

var secondName=prompt ("What is your Second Name?");

var userNameForSignUp=prompt ("What is your Username (for this 


site)?");

var passWordForSignUp=prompt ("What is your Password (for this 


site)?");

alert ("Thank You")+firstName;

document.write ("Your details are secured.")

}


else 

{

var userName=prompt ("What is your Username (for this site)?");

var passWord=prompt ("What is your Password (for this site)?");


if (userName == userNameForSignUp)

}

alert ("Welcome! Head to the link displayed on the page.");

document.write ("(Well, whatever the sites address is)")

}

</script>

The problem being, when I save it as .html (which is what I do for all my projects so far) and open it nothing happens.

Help would be great.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
You need to wrap it in the standard HTML tags.

Do you know HTML yet?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
amrosama

amrosama

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 8,674 posts
you have an error here:
alert ("Thank You")+firstName;
it should be
alert ("Thank You "+firstName);
check your browser error console to see whats wrong
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript

#4
hetra

hetra

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 298 posts

Quote

You need to wrap it in the standard HTML tags.

Do you know HTML yet?

Not until I made my WAMP Webmail Server. I know how to make a paragraph and center text. As much right now. I made the server today so yeah I'm pretty new to it.

Quote

you have an error here:

HTML Code:
alert ("Thank You")+firstName;
it should be

HTML Code:
alert ("Thank You "+firstName);
check your browser error console to see whats wrong

Oh thanks, I guess I missed that error.

The thing missing in my code is how to write to a text file. (If that's possible in JavaScript). I'm kinda obsessed with writing to text files in every language I know. (Don't know why).

Edited by Hunter100, 03 April 2010 - 03:45 AM.
Grammar.


#5
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
JavaScript doesn't, as I recall, support that. The browser generally won't allow that anyway, as a security concern.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog