help with web page

This is a discussion on "help with web page" within the Web Page Design section. This forum, and the thread "help with web page are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices


Closed Thread
 
LinkBack Thread Tools
  #1 (permalink)  
Old Oct 16th, 2003, 06:28
New Member
Join Date: Oct 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
help with web page

To all of you wise computer programmers,
I entered my text here below, and I am wondering how I would be able to add an "if" statement to the program that after the "confirm,"the program will display an alety box with an error message, if the user presses "cancel" instead of OK? Thank you very much for your time and help.


<HTML>
<Head>
<TITLE>JAVAScript</TITLE>
</Head>



<BODY>

<Script Language:"javascript">
var x= window.prompt("How many Home PC's would you like?>>");
var y= window.prompt("How many Gamer PC's would you like?>>");
var z= window.prompt("How many business PC's would you like?");
var pu= window.prompt("How many Power user PC's would you like?");
window.confirm("Home PC's = "+x+" Gamer PC's ="+y);
window.confirm("Business PC's ="+z+" Power User PC's ="+pu);
var M = ((x*1)+(y*1)+(z*1)+(pu*1))
var R = ((x*1)+(y*2)+(z*4)+(pu*4))
var C = ((x*1)+(y*0)+(z*1)+(pu*1))
var D = ((x*0)+(y*1)+(z*0)+(pu*1))



document.write("For "+x+" Home PCs, "+y+" Gamer PCs, "+z+" Business PCs, and "+pu+" Power User PCs, you will need to order:");

document.write("

"+M+" Motherboard(s) </p>");

document.write("

"+R+" RAM Module(s) </p>");

document.write("

"+C+" CD/RW drive(s) </p>");

document.write("

"+D+" DVD drive(s) </p>");

document.write("<h1>CALCulator</h1>");1

</script>
</body>
</html>

  #2 (permalink)  
Old Oct 16th, 2003, 08:17
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Is this what you are looking for?

Code: Select all
<HTML>
<Head>
<TITLE>JAVAScript</TITLE>
</Head>



<BODY>

<Script Language:"javascript">
var x= window.prompt("How many Home PC's would you like?>>");
var y= window.prompt("How many Gamer PC's would you like?>>");
var z= window.prompt("How many business PC's would you like?");
var pu= window.prompt("How many Power user PC's would you like?");
if (x != null && y != null && z != null && pu != null){
	window.confirm("Home PC's = "+x+" Gamer PC's ="+y);
	window.confirm("Business PC's ="+z+" Power User PC's ="+pu);
	var M = ((x*1)+(y*1)+(z*1)+(pu*1))
	var R = ((x*1)+(y*2)+(z*4)+(pu*4))
	var C = ((x*1)+(y*0)+(z*1)+(pu*1))
	var D = ((x*0)+(y*1)+(z*0)+(pu*1))
	
	document.write("For "+x+" Home PCs, "+y+" Gamer PCs, "+z+" Business PCs, and "+pu+" Power User PCs, you will need to order:");

	document.write("

 "+M+" Motherboard(s) </p>");

	document.write("

 "+R+" RAM Module(s) </p>");

	document.write("

 "+C+" CD/RW drive(s) </p>");

	document.write("

 "+D+" DVD drive(s) </p>");

	document.write("<h1>CALCulator</h1>");
	}
else{
	document.write("You cancelled")}

</script>
</body>
</html>
HTH
u2o
  #3 (permalink)  
Old Oct 16th, 2003, 14:54
New Member
Join Date: Oct 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
u2orange, thank you so very much for helping me!
However, what I need is a little different. The program contains a prompt box as a confirm method. So the program assumes that the user presses ok in the prompt box. However, I would like to have an if statement that will have an alert box with an error message, if the user presses "cancel" instead of "ok" for the prompt.

Thank you again very much for your time and willingness to help.
  #4 (permalink)  
Old Oct 16th, 2003, 14:57
New Member
Join Date: Oct 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
In my last response it may have been not clear also, I'm sorry. I just wanted to have an alert box pop up with an error message if the user presses "cancel" when he is asked to confirm the choice that he made.
  #5 (permalink)  
Old Oct 16th, 2003, 15:07
Reputable Member
Join Date: Aug 2003
Location: United Kingdom
Posts: 158
Thanks: 0
Thanked 0 Times in 0 Posts
Okay, just replace the line
Code: Select all
document.write("You cancelled")
with
Code: Select all
alert("your message here")
u2o
  #6 (permalink)  
Old Oct 16th, 2003, 19:23
New Member
Join Date: Oct 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you again very much u2orange for your help.
However, you slightly misunderstood what I am trying to do. I need for there to be an alert box pop up with a message, only when the user clicks cancel on the confirm message.
Basically, the user should make his 4 selections, and then he is asked to again confirm all of them with an "ok" or "cancel." And then is when the user will press cancel, and then an alert message should pop up.
Also, I was wondering if you could help me put all of the "confirms" in one pop up box instead of two as they are now. For some reason I couldn't get them into only one before.

Thank you again very much for your time, patience, and knowledge.
  #7 (permalink)  
Old Oct 16th, 2003, 19:35
New Member
Join Date: Oct 2003
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you but I actually figured out how to do that using your help. It goes like this just changing the location of the if statement. And I would also like to know if it's possible to combine the two confirms into one. Thanks a bunch!


<BODY>

<Script Language:"javascript">
var x= window.prompt("How many Home PC's would you like?>>");
var y= window.prompt("How many Gamer PC's would you like?>>");
var z= window.prompt("How many business PC's would you like?");
var pu= window.prompt("How many Power user PC's would you like?");

window.confirm("Home PC's = "+x+" Gamer PC's ="+y);
window.confirm("Business PC's ="+z+" Power User PC's ="+pu);
if (x == null && y == null && z == null && pu == null){
var M = ((x*1)+(y*1)+(z*1)+(pu*1))
var R = ((x*1)+(y*2)+(z*4)+(pu*4))
var C = ((x*1)+(y*0)+(z*1)+(pu*1))
var D = ((x*0)+(y*1)+(z*0)+(pu*1))

document.write("For "+x+" Home PCs, "+y+" Gamer PCs, "+z+" Business PCs, and "+pu+" Power User PCs, you will need to order:");

document.write("

"+M+" Motherboard(s) </p>");

document.write("

"+R+" RAM Module(s) </p>");

document.write("

"+C+" CD/RW drive(s) </p>");

document.write("

"+D+" DVD drive(s) </p>");

document.write("<h1>CALCulator</h1>");
}
else{
alert("Error: Please reload the page and re-enter the data!")};

</script>
</body>
</html>
Closed Thread

Tags
help, web, page

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Best way to prevent access to page B except via page A? Donny Bahama PHP Forum 1 Apr 3rd, 2008 02:15
Green bar of colour at bottom of page gets bigger the more page is extended pixelgirl Web Page Design 1 Apr 1st, 2008 01:27
internal navigation, Linking from one page to a specific div in another page. Oak Web Page Design 5 Feb 8th, 2008 22:54
Linking an outside page back to previous framed page MJustison Starting Out 1 Oct 18th, 2007 17:49
A gap appears beween the Page Title and the Body Content of the page. sovereign6 Web Page Design 6 Dec 18th, 2006 19:14


All times are GMT. The time now is 02:43.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43