There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen blue screen of death boot bsod computer connection crash css dell display driver drivers email error firefox firefox 3 hard drive internet internet explorer itunes laptop lcd malware monitor network networking nvidia outlook outlook 2003 outlook express partition password printer problem ram router security slow software sound trojan usb video virus vista windows windows xp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Javascript switch figure help


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
Animesing's Avatar
Member with 44 posts.
 
Join Date: Oct 2004
25-Sep-2007, 04:01 PM #1
Javascript switch figure help
I am trying to create a script that allows a prompt to pop up and ask a question refering to shapes and it gives an option to choose through the number 1-5 and i am trying to use the switch statement in order to ask 1 or 2 questions about the length, width or height depending on which one they choose so that those variables can be thrown into an equation so it can figure out the area or volume etc of a shape. I am having trouble with the switch statement. Can someone help me out on this?
MMJ's Avatar
MMJ MMJ is offline
Distinguished Member with 3,250 posts.
 
Join Date: Oct 2006
25-Sep-2007, 04:25 PM #2
does it pop up a page or popup box?

There are three types of js popup boxes.
1. alert
2. confirm
3. prompt

Please post any code you have written.

http://www.w3schools.com/js/js_popup.asp
Animesing's Avatar
Member with 44 posts.
 
Join Date: Oct 2004
25-Sep-2007, 04:54 PM #3
prompt

the first popup should look something like this i made.

<script type="text/javascript">
document.write('<div style="text-align:center">');
document.write('<h1>');
document.write("Geometry Calculator");

var figure = "Please Select a figure from the following list (enter a number):";
var figure = figure + "<br /> \n (1) cone \n (2) cube \n (3) cylinder \n (4) prism \n (5) pyrimid";
var figure = parseFloat(prompt(figure, "1"));

</script>

---------
now how to i make certain popups say for example

(1) cone ask for 2 popup windows asking
1. what is the height
2. what is the radius

i am trying to use something to this effect.

switch (figure){
case "1":
function computeCone(radius, height)
{var radius = prompt("Please enter the radius of the base (in inches):", "5");
var height = prompt("Please enter the height (in inches):", "8"); }
break;
case "2":
function computeCube(length)
{var length = prompt("Please enter the length of a base edge (in inches):", "3");}
break;
case "3":
function computeCylinder(radius, height)
{var radius = prompt("Please enter the radius of the base (in inches):", "5");
var height = prompt("Please enter the height (in inches):", "8");}
break;
case "4":
function computePrism(length, height)
{var length = prompt("Please enter the length of a base edge (in inches):", "3");
var height = prompt("Please enter the height (in inches):", "8");}
break;
case "5":
function computePyrimid(length, height)
{var length = prompt("Please enter the length of a base edge (in inches):", "3");
var height = prompt("Please enter the height (in inches):", "8");}
break;

}
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:53 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.