Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


Javascript help, i need to store a users details



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
pumpkin



Joined: 11 May 2008
Posts: 3

PostPosted: Sat Jun 21, 2008 10:13 pm    Post subject: Javascript help, i need to store a users details Reply with quote

Hello,

i'm new to javascript and i have an assignment which is proving very difficult. Its basically a registration form and the user enters their selection ie option 1,2 or 3 with option 3 terminating the programme. I've managed to get as far as having the user select option 3 to terminate the programme and present them with a goodbye message. Also if they select option 1 they enter their name and surname and age, and they get a welcome message, again i've managed that bit too however, here is where i am lost. If they select option 2 the system provides the user with a 'name' this being the first letter of their first name and the first letter of their surname a hyphen and then their age (using the information they entered in option 1), the system also provides a 'password' this being their age, the last letter of their firstname and the last letter of their surname, ((using the information they entered in option 1).
Can anyone help me with how i can acheive this? i've entered my code below

<HTML>
<HEAD>
<TITLE> ONLINE REGISTRATION TEST</TITLE>

<SCRIPT

language="JavaScript"
type="text/javascript">

var forename;
var surname;
var name;
var age, ageDiff;
var password;
var option;
option = 0;

document.write('ONLINE REGISTRATION'+'<BR>'+
'============================='+'<BR>'+
'What would you like to do?'+'<BR>'+
'<OL>'+
'<LI>'+'Register as a new user'+'</LI>'+
'<LI>'+'View your details'+'</LI>'+
'<LI>'+'Exit'+'</LI>'+
'</OL>'+
'Enter 1, 2 or 3 to select'+'<BR>')

while (option != 3)
{
option = window.prompt('Please select an option between 1 and 3.','');
option = parseFloat(option);
while (option < 1 || option > 3)
{
option = window.prompt('You must select an option between 1 and 3.','');
option = parseFloat(option);
}

if (option == 1)
{
forename = window.prompt('Please enter your forename ','');
surname = window.prompt('Please enter your surname ', '');
age = window.prompt('Please enter your age ', '');
age = parseFloat(age);
}
if (age < 5 || age > 50)
{
age = window.prompt('Please re enter your age ', '');
age = parseFloat(age);
}
if (age < 5)
{
ageDiff = (5 - age)
document.write('<BR>'+'Sorry, you are too young. Come back in ' + ageDiff + ' year.');
}
else if (option == 1){
{
document.write('<BR>'+'Thank you, ' + forename + ' ' + surname + '.' + ' You have successfully registered .'+'<BR>');
}
if (option == 2)
{
name = forename
password = surname
document.write('Your user name is ', ' + forename + ','');
document.write('Your password is ', ' + surname + ','');
}
}
}
document.write('<BR>'+'GOODBYE ');

</SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap