...

View Full Version : Javascript help needed please!!



Tallyho
06-14-2008, 07:50 PM
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????

Philip M
06-14-2008, 08:57 PM
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."

Tallyho
06-14-2008, 09:05 PM
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

liorean
06-14-2008, 09:38 PM
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...

Tallyho
06-14-2008, 09:46 PM
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

liorean
06-14-2008, 11:15 PM
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 agianGreat 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.

Philip M
06-15-2008, 09:02 AM
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.

Philip M
06-15-2008, 09:07 AM
Which brand? Husqvarna? I've seen similar warnings, but not that one...

http://www.dumbwarnings.com/warnings.php?site=warnings&cid=13



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum