# One must start from somewhere....

• 07-11-2012, 11:06 AM
theCuriousCoder
One must start from somewhere....
Hi, I'm learning JS, and I need help. Here is my code:
Code:

```//This object is going to be used //so that at the end of the calcCost function, //the client can see the subtotal, tax, and grandtotal //in a portion of the webpage. Like a console, mayhaps. var dataWindow=new Object(); dataWindow.height=80; dataWindow.width=500; //This is the function that takes the subtotal, tax and grandtotal and simply displays them in //the data window. dataWindow.showResults=function(subtotal,tax,grandtotal){         return "Subtotal" + subtotal;         return "Tax" + tax;         return "Grandtotal" + grandtotal; } //This is the function that calculates the subtotal, tax and grandtotal. function calcCost(){ var itemCost=prompt("Enter the cost of the item here.");         var subtotal=itemCost;                 document.write("Subtotal" + subtotal);         var tax=.0825;                 document.write("Tax Charge" + tax);         var grandtotal=(subtotal*tax);                 document.write("Grand Total" + grandtotal);         dataWindow.showResults();//this call of the function should take the  subtotal,tax and grandtotal         //and display them in the dataWindow. }```
I truly appreciate the help, and realize this is probably the stupidest code you've all laid eyes on. I apologize, but one must start from SOMEWHERE.
• 07-11-2012, 06:25 PM
Gray1989
Code:

```function calcCost() { var cost = prompt("Enter the cost of the item here."); var tax = 0.0825; alert("Subtotal: "+cost+"\nTax Charge: "+(cost*tax)+"\nGrand Total: "+((1+tax)*cost)); }```
Is that what you were looking for?
• 07-12-2012, 10:50 AM
theCuriousCoder
the
Code:

`function calcCost`
isn't what I had the problem with, its the
Code:

`dataWindow`
object. I made the object because i wanted to be able to have it dynamically update with the subtotal,grandtotal and tax parameters.
• 07-12-2012, 01:53 PM
Gray1989
You may want to look into the uses of "window.showModalDialog"

## X vBulletin 4.2.2 Debug Information

• Page Generation 0.11960 seconds
• Memory Usage 2,348KB
• Queries Executed 11 (?)
Template Usage (20):
• (4)bbcode_code_printable
• (1)footer
• (1)gobutton
• (1)navbar_moderation
• (1)navbar_noticebit
• (2)option
• (1)spacer_close
• (1)spacer_open

Phrase Groups Available (3):
• global
• postbit
Included Files (19):
• ./global.php
• ./includes/class_bootstrap.php
• ./includes/init.php
• ./includes/class_core.php
• ./includes/config.php
• ./includes/functions.php
• ./includes/class_friendly_url.php
• ./includes/class_hook.php
• ./includes/class_bootstrap_framework.php
• ./vb/vb.php
• ./vb/phrase.php
• ./includes/functions_calendar.php
• ./includes/class_bbcode_alt.php
• ./includes/class_bbcode.php
• ./includes/functions_bigthree.php
• ./includes/functions_notice.php

Hooks Called (41):
• init_startup
• init_startup_session_setup_start
• database_pre_fetch_array
• database_post_fetch_array
• init_startup_session_setup_complete
• global_bootstrap_init_start
• global_bootstrap_init_complete
• cache_permissions
• fetch_foruminfo
• global_state_check
• global_bootstrap_complete
• global_start
• style_fetch
• global_setup_complete
• bbcode_fetch_tags
• bbcode_create
• bbcode_parse_start
• cache_templates
• cache_templates_process
• template_register_var
• template_render_output
• fetch_template_start
• fetch_template_complete
• parse_templates