Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Javascript help needed please!!

    Hello i'm very new to Javascript and having a really hard time doing an assignment, and ant help would be really appreciated. I have to create some coding that prompts a user to enter their selection from 1 - 3 selcting 3will terminate the programme and so far i have managed to get that bit to work. Now i have to create code that, when a user delects 1 i have to store their details ie firstname last name age etc. This is where i need help, the code i am using is as follows but it does not work;
    language="JavaScript"
    type="text/javascript">

    var readerForename;
    var readerSurname;
    var readerName;
    var readerAge, ageDiff;
    var password;
    var option;
    option = 0;

    document.write('BARSETSHIRE COUNTY LIBARARIES'+'<BR>'+
    '============================='+'<BR>'+
    'What would you like to do?'+'<BR>'+
    '<OL>'+
    '<LI>'+'Register as a reader'+'</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);
    }
    }
    document.write('<BR>'+'GOODBYE ');
    if (option == 1)
    {
    readerForename = window.prompt('Please enter your forename ','');
    readerSurname = window.prompt('Please enter your surname ', '');
    readerAge = window.prompt('Please enter your age ', '');
    readerAge = parseFloat(readerAge);
    }
    if (readerAge < 5 || readerAge > 120)
    {
    readerAge = window.prompt('Please re enter your age ', '');
    readerAge = parseFloat(readerAge);
    }
    if (readerAge < 5)
    {
    ageDiff = (5 - readerAge)
    document.write('Sorry. You are too young. Come back in ' + ageDiff + ' year.');
    }
    else
    {
    document.write('<BR>'+'Thank you, ' + readerForename + ' ' + readerSurname + '.' + ' You are now a member of Barsetshire Libraries.');
    }

    can someone please help????

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,082
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    If you had used the search feature you would have found

    http://www.codingforums.com/showthread.php?t=141040

    JavaScript is purely a client-side language, and has no capability to read from or write to a file (except a cookie), access a database or the client's operating system. So you cannot "store" the user details.

    Do please read the posting guidelines regarding silly thread titles. The thread title is supposed to help people who have a similar problem in future. Yours is useless for this purpose.

    Instructions on a Swedish chainsaw -- "Do not attempt to stop chain with your hands or genitals."

  • #3
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    sorry for any confusion, as i said i am very new to Javascript and as such new to using forums such as this one. I will try not to offend or upset anyone in the future with 'silly threads', but please understand that we are not all very experienced in this area and as such to have to ask for help

    apologies again

  • #4
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Quote Originally Posted by Philip M View Post
    Instructions on a Swedish chainsaw -- "Do not attempt to stop chain with your hands or genitals."
    Which brand? Husqvarna? I've seen similar warnings, but not that one...
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #5
    New to the CF scene
    Join Date
    Jun 2008
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you Liorean,

    I am 58 and not as quick at learning things like i used to be. I can see that Javascript is going to be a long and steep learning curve for me!!

    thanks agian

  • #6
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Quote Originally Posted by Tallyho View Post
    Thank you Liorean,

    I am 58 and not as quick at learning things like i used to be. I can see that Javascript is going to be a long and steep learning curve for me!!

    thanks agian
    Great use of sarcasm there

    Philip did link a thread that addresses your specific assignment though, so I felt like your problem had already been dealt with.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #7
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,082
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by Tallyho View Post
    sorry for any confusion, as i said i am very new to Javascript and as such new to using forums such as this one. I will try not to offend or upset anyone in the future with 'silly threads', but please understand that we are not all very experienced in this area and as such to have to ask for help

    apologies again
    There is no need to grovel. But if you start off by reading the posting guidelines and the thread "How to post a JavaScript question" you will greatly improve your chances of attracting the interest and responses of other users of the forum.

  • #8
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,082
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by liorean View Post
    Which brand? Husqvarna? I've seen similar warnings, but not that one...
    http://www.dumbwarnings.com/warnings...arnings&cid=13


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •