Webmaster Forum


Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Coding Forum Problems with your code? Let's hear about it.

Easy Date   Perfect Money   V7N Directory

Reply
 
LinkBack Thread Tools Display Modes
Old 01-03-2007, 09:04 PM   #1 (permalink)
Inactive
 
Join Date: 01-03-07
Posts: 1
iTrader: 0 / 0%
Latest Blog:
None

jazco is liked by many
How to do a price calculator

I am trying to create a price calculator that automatically calculates the price of custom made picture frame. I got an equation that finds the square area of the frame by multiplying the perimeter (2*length*width) by the thickness (which the user can choose from 1.5", 2" or 3"). Then it multiplies it by a decimal number (0.27 if the frame is 1.5" thick, 0.23 if its 2" thick, and 0.18 if its 3" thick). Then it adds a $5 custom made fee to the final answer. But when I save it to an html file and load it in Internet Explorer, it doesn't calculate. Do you guys have an idea how to make it work?

<SCRIPT LANGUAGE="JavaScript">
function calculate_total(){
var length = Number(document.
getElementById('calc').
length.value);
var width = Number(document.
getElementById('calc').
width.value);
var frame = Number(document.
getElementById('calc').
frame.options
[document.getElementById('calc...
frame.options.
selectedIndex].value);
var total = (2 * (length + width)) * frame;
switch (frame){
case 1.5:
total = total * 0.27;
break;
case 2:
total = total * 0.23;
break;
case 3:
total = total * 0.18;
break;
}

document.getElementById('calc'... = total + 5;
}
</script>

Sorry the cut off code so you might have to concatenate some lines above this if you have questions let me know.
And here is the form I used, again its very basic but it works.

<form name="calc" id="calc">
Length: <input type="text" name="length" onchange="calculate_total()" /><br />
Width: <input type="text" name="width" onchange="calculate_total()" /><br />
<select name="frame" onchange="calculate_total()">
<option value="0" selected>Select a Frame</option>
<option value="1.5">1.5" Narrow Barnwood</option>
<option value="2">2" Rustic Barnwood</option>
<option value="3">3" Thick Barnwood</option>
</select>
<br />
<br />
Total: <input id="total" name="total"/>
</form>
jazco is offline  
Add Post to del.icio.us
Reply With Quote
Sponsored Links
SEO Hosting by HostGator  Advertise Here  Buy Blog Links
Old 01-04-2007, 01:17 PM   #2 (permalink)
v7n Mentor
 
Taltos's Avatar
 
Join Date: 11-22-06
Location: Phoenix, AZ
Posts: 1,788
iTrader: 0 / 0%
Latest Blog:
None

Taltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web proTaltos is a highly respected web pro
Send a message via Yahoo to Taltos
I took a quick look and I don't see anything that stand out as an immediate problem. One thing I have seen is using the DOM calls directly in a calculation seems to be quirky. Sometimes it works and sometimes it doesn't. I usually do:

var formdata = document.getElementById('calc');
var length = document.formdata.length.value;
length = Number(length);

It makes for longer code but seems to be more stable and makes troubleshooting easier. You can output to an alert any point of your data manipulation to see what is going on.

Do you get any errors or it just never calculates?
__________________
Experimenting
Taltos is offline  
Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Web Design Lobby > Coding Forum

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

vB 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
Does anybody know about SERP calculator? Nikhil SEO Forum 12 11-08-2007 11:03 AM
Job Salary Calculator DharmaConsulting Marketing Forum 4 03-16-2007 09:06 AM
Birthday Calculator John Scott Forum Lobby 4 11-23-2006 07:31 AM
PR Calculator world4health SEO Forum 6 02-23-2004 03:08 PM


Sponsor Links
Get exposure! Get exposure! Find Scripts Web Hosting Directory Get exposure! SEO Blog


All times are GMT -7. The time now is 05:43 AM.
© Copyright 2008 V7 Inc