Tallyho
Jun 17th, 2008, 10:50 AM
Hi I'm reposting my coding problem as i still cannot get it to work. As i'm new to all this it's probably something very simpler that's missing but anyhelp would be appreciated. Her is my origianl message;
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('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 the Library.');
}
can someone please help????
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('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 the Library.');
}
can someone please help????