Submit Your Article Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > JavaScript

Reply
 
LinkBack Thread Tools
Old June 21st, 2008, 10:43 AM   #1
New Member
 

Join Date: Jun 2008
Location: Scotland
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 pumpkin is on a distinguished road
Question Javascript String processing

Hi all,

i'm a complete newbie and having real trouble with an assignment using javascript. I'm trying to create some code that allows a user to select some options ie 1 to join the club, where they have to enter their name and age (if they are too young they are told to come back in X years) and i've managed that bit fine. However if they select option 2 they need to be able to view their details ie a 'name' and password which has automatically beed allocated to them using the informaiton they entered at option 1 (in this case the name is the first letter of their first and lat names as well as their age), this is where i'm in a guddle as i've no idea how to do this. Here is the code fo far and i'd be really grateful for any help as it's all getting a bit too confusing for me;

Code:
var forename; 
var surname;
var name;
var age, ageDiff;
var password;
var option; 
option = 0;
 
 
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 > 120)
{
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 are now a member.'+'<BR>');
}
}
if (option == 2) - this is where i am confused 
{
name = ???
password = ????
document.write('<BR>'+'Your username is,' + name + ' '+'<BR>');
}
}
} 
document.write('<BR>'+'Goodbye');

Last edited by Aso; June 21st, 2008 at 11:27 AM.. Reason: Please use [code] tags
pumpkin is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Decoding a string in Javascript omega113 JavaScript 1 June 12th, 2008 12:07 PM
Javascript problem - unterminated string jitumandalia JavaScript 2 February 14th, 2008 03:43 AM
Problem with ["] and ['] in javascript string beckkp JavaScript 3 September 13th, 2007 02:20 AM
problems with form processing tooie Classic ASP 3 April 26th, 2006 01:34 PM
Template Processing vor Classic ASP 3 September 9th, 2003 08:01 PM


Search Engine Optimization by vBSEO 3.2.0 RC8