Click to See Complete Forum and Search --> : Simple javascript code
An Fear Marbh
04-23-2003, 05:37 PM
Greetings all you javascript experts. I am smiling at my subject description above. If it was that simple I wouldn't be here seeking help. I am a mature student doing a diploma in Information Systems management. I have designed a web sit as part of my project. A requirement of the project is to include a script that requires user input. My idea is to ask the user to choose from three different accomodation types. They will then be prompted to enter the number of days they wish to stay. Output will give them the total cost. The script must include arrays and functions. Could anyone point me to a site wher I mifght pick up some tips on how to go about this, or maybe one of you has an idea that might help me.
JackTheTripper
04-23-2003, 05:48 PM
Go to www.webmonkey.com and click on "Programming > Javascript" Do Thou's JS tutorial and his advanced tutorial. You should be able to run through them in 4 or 5 hours, less if you skip the slower parts.
Good luck on your project! :D
An Fear Marbh
04-23-2003, 06:01 PM
Thanks Jack. Trust all is well in the valley and that the law enforcement people there can spell.
An Fear Marbh
04-24-2003, 03:01 AM
Thanks David,
Frankly, I only started learning javascript last september. I have to be honest it is absolutely scrambling my 48 yr old brains. I appreciate the help. My lecturer cannot undererstand how anyone could have difficulty with this stuff. I just do not want to give him the satisfaction.
An Fear Marbh
04-24-2003, 03:11 PM
David,
It is my intention to tell my lecturer that i "TOOK" THE SCRIPT FROM THE 'NET AND TWEAKED IT FOR MY PROJECT. i HAVE MADE SOME CHANGES TO WHAT YOU POSTED AND i THINK i UNDERSTAND WHAT YOU HAVE DONE (WELL MOST OF IT). S*** I'll have to learn to type as well. Any hints! *s*. I wouldn't dream of trying to pull the wool over his eyes on this one, he is all too aware what I am capable of,,,Again,, many thanks...You have saved me the price of two blood pressure and one tranquiliser pills
Kevin
An Fear Marbh
04-25-2003, 05:52 PM
David,
Felt a bit guilty about taking your script for my own so got out the books and applied myself a little to the task. A few "tech support" phone calls and I ended up with this. Not as pretty as yours when it is run but functional all the same, and more in keeping with what we have been learning. Again thank you.
Kevin
<script LANGUAGE="JavaScript" type="text/javascript">
var price = new Array();
price[1]=55.00;
price[2]=37.50;
price[3]=90.00;
price[4]=125.00;
var room;
alert("Please enter the number code that matches your accomodation needs 1.Single Room 2.Single Room Sharing 3.Double Room 4. Family suite");
get_room();
var duration = Number(prompt("Please enter the duration of your stay"))
total();
function get_room(){
room = Number(prompt("Please enter room code"));
if(room>4){
alert("Please enter a valid code 1 - 4");
get_room();
}
if(room<1){
alert("Please enter a valid code 1 - 4");
get_room();
}
}
function total(){
TotalPrice = price[room]*duration;
alert("The total cost of your stay will be €" + TotalPrice);
alert("Please fill in the booking form below");
}
<!--
//-->
</script>