[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 02-17-2006, 03:27 AM   #1 (permalink)
Senior Member
 
Xyzer's Avatar
 
Join Date: Aug 2005
Location: United Kindom
Posts: 1,506
90.70 NP$ (Donate)

Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all

Tsunami Relief AIDS/HIV
50NP For Help

Hi,

I will pay the person who helps me with my little coding problem 50np.

So,
The problem is i have my own build your own pc confiurator. On the upgrades page i have a little menu in which you choose the upgrade. I want to be able to have a price at the bottom of the page that says the price and when someone changes an option the price at the bottom automatically updates.

I know it wont take long but dont know how to do it.

Thanks
Steven
Xyzer is offline  
Old 02-17-2006, 03:58 AM   #2 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services

 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
Hmm, pretty sure you'd want to use onChange etc.. javascript is definitely not my strong point..but:

Code:
<html>
<head>
<script language="javascript" type="text/javascript">
<!--
function up_price()
{
  box = document.forms[0].upgrade;
  price = box.options[box.selectedIndex].value;
  if (price) document.forms[0].pri.value = price;
}
// -->
</script>
</head>

<body>

<form>
<select name="upgrade" onChange="up_price()">
<option name="upgrade1" value="9.97">upgrade1
<option name="upgrade2"value="9.98">upgrade2
<option name="upgrade3" value="9.99">upgrade3
</select>
<br><br>
<input type="text" name="pri" value="">
</form>

</body>
</html>
__________________

Last edited by SecondVersion; 02-17-2006 at 04:00 AM. Reason: hmm, something weird goin on with [HTML][/HTML]
Eric is offline  
Old 02-17-2006, 04:18 AM   #3 (permalink)
Senior Member
 
Xyzer's Avatar
 
Join Date: Aug 2005
Location: United Kindom
Posts: 1,506
90.70 NP$ (Donate)

Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all

Tsunami Relief AIDS/HIV
Hi thanks for this code.

When i put the code into my document it isnt working for me would it work if it was in a seperate js file?

The code i have so far it: but it isnt working:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript" type="text/javascript">
<!--
function up_price()
{
  box = document.forms[0].upgrade;
  price = box.options[box.selectedIndex].value;
  if (price) document.forms[0].pri.value = price;
}
// -->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SR COMPUTERS INTEL PACKAGES ORDER</title>

</head>
<body bgcolor="#3399FF">
<center>
<h3><u>Order Home Package</u></h3></center>
<h4>Choose any Upgrades you want:</h4>
<p>Please note if you purchase and upgrades the packages default item will not be included and replaced with the upgraded part.</p>
<form method="POST" action="thanks.php" name="Order Home Package">
<input type="TEXT" name="name" value="Enter Name">
<input type="TEXT" name="email" value="Enter Email Address">
<h5>CD Drive Upgrades:</h5>
<form method="post" action="thanks.php" name="CD Drive Upgrades">
<select name="CD Drive Upgrade" onChange="up_price() ">
<option name="No Upgrades">No Upgrades
<option name="1 X DVD-RW All Formats">1 X DVD-RW All Formats [Add £25]
<option name="2 X DVD-RW All Formats">2 X 1 X DVD-RW All Formats [Add £35]
</select>
<input type="text" name="pri" value="">
<h5>Memory Upgrades:</h5>
<form method="post" action="thanks.php" name="Memory Upgrades></form>">
<select name="Memory Upgrades">
<option value="No Upgrades">No Upgrades
<option value="2 x 512MB - 1GB Memory [Add £30]">2 x 512MB - 1GB Memory [Add £30]
<option value="2 x 1GB - 2GB Memory [Add £60]">2 x 1GB - 2GB Memory [Add £60]
<option value="Degrade Memory to 256MB [Take £15]">Degrade Memory to 256MB [Take £15]
</select>
<h5>Case Upgrades:</h5>
<form method="post" action="thanks.php" name="Case Upgrades></form>">
<select name="Case Upgrades">
<option value="No Upgrades">No Upgrades
<option value="See Through Window [Add £20]">See Through Window [Add £20]
<option value="See Through Window and Cold Cathode CCFL Lights [Add £35]">See Through Window and Cold Cathode CCFL Lights [Add £35]
</select>
<h5>Hard Disk Upgrades:</h5>
<form method="post" action="thanks.php" name="Hard Disc Upgrades></form>">
<select name="Hard Disk Upgrades">
<option value="No Extras">No Extras
<option value="120GB Hard Disk [Add £20]">120GB Hard Disk [Add £20]
<option value="160GB Hard Disk [Add £35]">160GB Hard Disk [Add £35]
</select>
<h5>Networking Upgrades:</h5>
<form method="post" action="thanks.php" name="Networking Upgrades></form>">
<select name="Networking Upgrades">
<option value="No Extras">No Extras
<option value="Gigabit Ethernet [Add £35]">Gigabit Ethernet [Add £35]
<option value="Built In Wireless [Add £35]">Built In Wireless [Add £35]
</select>
<br>

<br>
<br>
<input type="SUBMIT" name="Submit" value="Submit" src="thanks.php">
<input type="RESET" name="Reset">
</form>
</body>
</html>
Xyzer is offline  
Old 02-17-2006, 08:18 AM   #4 (permalink)
NamePros Member
 
Join Date: Feb 2006
Location: Chicago IL
Posts: 73
25.00 NP$ (Donate)

AllValley is an unknown quantity at this point


What does blue * yellow equal?

You're right. You can't mutliply text!


A tip:
For XHTML compliance, close all tags.
Another Tip:
You only need one form action="" per form, not per select.
another tip:
values should be numbers, names are text.

This may work, if it doesn't I'll work on it a little more.

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script language="javascript" type="text/javascript">
<!--
function up_price()
{
  box = document.forms[0].upgrade;
  price = box.options[box.selectedIndex].value;
  if (price) document.forms[0].pri.value = price;
}
// -->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SR COMPUTERS INTEL PACKAGES ORDER</title>

</head>
<body bgcolor="#3399FF">
<center>
<h3><u>Order Home Package</u></h3></center>
<h4>Choose any Upgrades you want:</h4>
<p>Please note if you purchase and upgrades the packages default item will not be included and replaced with the upgraded part.</p>
<form method="POST" action="thanks.php" name="Order Home Package">
<input type="TEXT" name="name" value="Enter Name" />
<input type="TEXT" name="email" value="Enter Email Address" />
<h5>CD Drive Upgrades:</h5>

<select name="CD Drive Upgrade" onChange="up_price() ">
<option selected name="No Upgrades">No Upgrades</option>
<option name="1 X DVD-RW All Formats" value="25">1 X DVD-RW All Formats [Add £25]</option>
<option name="2 X DVD-RW All Formats" value="35">2 X 1 X DVD-RW All Formats [Add £35]</option>
</select>
<input type="text" name="pri" value="" />
<h5>Memory Upgrades:</h5>

<select name="Memory Upgrades" onChange="up_price()">
<option value selected name="No Upgrades""0">No Upgrades</option>
<option name="2 x 512MB - 1GB Memory [Add £30]" value"30">2 x 512MB - 1GB Memory [Add £30]</option>
<option name="2 x 1GB - 2GB Memory [Add £60]" value"60">2 x 1GB - 2GB Memory [Add £60]</option>
<option name="Degrade Memory to 256MB [Take £15]" value"-15">Degrade Memory to 256MB [Take £15]</option>
</select>
<h5>Case Upgrades:</h5>

<select name="Case Upgrades" onChange="up_price()">
<option value selected namr="No Upgrades""0">No Upgrades</option>
<option name="See Through Window [Add £20]" value"20">See Through Window [Add £20]</option>
<option name="See Through Window and Cold Cathode CCFL Lights [Add £35]" value"35">See Through Window and Cold Cathode CCFL Lights [Add £35]</option>
</select>
<h5>Hard Disk Upgrades:</h5>

<select name="Hard Disk Upgrades" onChange="up_price()">
<option value selected name="No Extras""0">No Extras</option>
<option name="120GB Hard Disk [Add £20]" value"20">120GB Hard Disk [Add £20]</option>
<option name="160GB Hard Disk [Add £35]" value"35">160GB Hard Disk [Add £35]</option>
</select>
<h5>Networking Upgrades:</h5>
<select name="Networking Upgrades" onChange="up_price()">
<option value selected name="No Extras""0">No Extras</option>
<option name="Gigabit Ethernet [Add £35]" value"35">Gigabit Ethernet [Add £35]</option>
<option name="Built In Wireless [Add £35]" value"35">Built In Wireless [Add £35]</option>
</select>
<br>

<br>
<br>
<input type="SUBMIT" name="Submit" value="Submit" src="thanks.php">
<input type="RESET" name="Reset">
</form>
</body>
</html>
As a side note, what's the php this fees into?

Also, I think you need to create a layer or div that calls that JS. Note sure how to call JS so I wont mess with it. Maybe the other guy can help you out...

Off to Class!
__________________
Hassle Free Computing and Web Solutions for Personal and Business!
Rochelle Network Communications!

Last edited by AllValley; 02-17-2006 at 08:27 AM.
AllValley is offline  
Old 02-18-2006, 10:35 AM   #5 (permalink)
Senior Member
 
Xyzer's Avatar
 
Join Date: Aug 2005
Location: United Kindom
Posts: 1,506
90.70 NP$ (Donate)

Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all

Tsunami Relief AIDS/HIV
Hi,

I have got a new code off another forum and here it is:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>SR COMPUTERS INTEL PACKAGES ORDER</title>
<script>
update_price()
{
  var cost = 0;
  if (document.form1.CD Drive Upgrade.value == "No Upgrades") {then cost = cost + 0; }
  if (document.form1.CD Drive Upgrade.value == "1 X DVD-RW All Formats") {then cost = cost + 25; }
  if (document.form1.CD Drive Upgrade.value == "2 X DVD-RW All Formats") {then cost = cost + 35; }
  if (document.form2.Memory Upgrades.value == "No Upgrades") {then cost = cost + 0; }
  if (document.form2.Memory Upgrades.value == "1GB") {then cost = cost + 30; }
  if (document.form2.Memory Upgrades.value == "2GB") {then cost = cost + 60; }
  if (document.form2.Memory Upgrades.value == "256MB") {then cost = cost - 15; }
  if (document.form3.Case Upgrades.value == "No Upgrades") {then cost = cost + 0; }
  if (document.form3.Case Upgrades.value == "See Through Window [Add £20]") {then cost = cost + 20; }
  if (document.form3.Case Upgrades.value == "See Through Window and Cold Cathode CCFL Lights [Add £35]") {then cost = cost + 35; }
  if (document.form4.Hard Disk Upgrades == "No Upgrades") {then cost = cost + 0; }
  if (document.form4.Hard Disk Upgrades == "120GB Hard Disk [Add £20]") {then cost = cost + 20; }
  if (document.form4.Hard Disk Upgrades == "160GB Hard Disk [Add £35]") {then cost = cost + 35; }
  if (document.form5.Networking Upgrades.value == "No Upgrades") {then cost = cost + 0; }
  if (document.form5.Networking Upgrades.value == "Gigabit Ethernet [Add £35]") {then cost = cost + 35; }
  if (document.form5.Networking Upgrades.value == "Built In Wireless [Add £35]") {then cost = cost + 35; }
  document.form1.total.value = cost;
  document.form2.total.value = cost;
  document.form3.total.value = cost;
  document.form4.total.value = cost;
  document.form5.total.value = cost;
}
</script>
</head>
<body bgcolor="#3399FF">
<center>
<h3><u>Order Home Package</u></h3></center>
<p>The base price with no extras for this package is £470</p><br>
<p>To order a computer please fill in the form below and you will recieve and email back within 48 Hours with order conformation and order final price and a link to pay for your order.</p>
<h4>Choose any Upgrades you want:</h4>
<p>Please note if you purchase and upgrades the packages default item will not be included and replaced with the upgraded part.</p>
<form method="POST" action="thanks.php" name="Order Home Package">
<input type="TEXT" name="name" value="Enter Name">
<input type="TEXT" name="email" value="Enter Email Address">
<h5>CD Drive Upgrades:</h5>
<form method="post" action="thanks.php" name="form1"></form>
<select name="CD Drive Upgrade" onchange="update_price();">
<option value="No Upgrades">No Upgrades</option>
<option value="1 X DVD-RW All Formats">1 X DVD-RW All Formats [Add £25]</option>
<option value="2 X DVD-RW All Formats">2 X DVD-RW All Formats [Add £35]</option>
</select>
<h5>Memory Upgrades:</h5>
<form method="post" action="thanks.php" name="form2">
<select name="Memory Upgrades" onchange="update_price();">
<option value="No Upgrades">No Upgrades</option>
<option value="1GB">2 x 512MB - 1GB Memory [Add £30]</option>
<option value="2GB">2 x 1GB - 2GB Memory [Add £60]</option>
<option value="256MB">Degrade Memory to 256MB [Take £15]</option>
</select>
<h5>Case Upgrades:</h5>
<form method="post" action="thanks.php" name="form3">
<select name="Case Upgrades" onchange="update_price();">
<option value="No Upgrades">No Upgrades</option>
<option value="See Through Window [Add £20]">See Through Window [Add £20]</option>
<option value="See Through Window and Cold Cathode CCFL Lights [Add £35]">See Through Window and Cold Cathode CCFL Lights [Add £35]</option>
</select>
<h5>Hard Disk Upgrades:</h5>
<form method="post" action="thanks.php" name="form4">
<select name="Hard Disk Upgrades" onchange="update_price();">
<option value="No Upgrades">No Upgrades</option>
<option value="120GB Hard Disk [Add £20]">120GB Hard Disk [Add £20]</option>
<option value="160GB Hard Disk [Add £35]">160GB Hard Disk [Add £35]</option>
</select>
<h5>Networking Upgrades:</h5>
<form method="post" action="../Website/steve/thanks.php" name="form5">
<select name="Networking Upgrades" onchange="update_price();">
<option value="No Upgrades">No Upgrades</option>
<option value="Gigabit Ethernet [Add £35]">Gigabit Ethernet [Add £35]</option>
<option value="Built In Wireless [Add £35]">Built In Wireless [Add £35]</option>
</select>
<br>

<br>
<br>
<input type="text" name="total" </input>
<br>
<br>
<input type="SUBMIT" name="Submit" value="Submit" src="../Website/steve/thanks.php">
<input type="RESET" name="Reset">
</form>
</body>
</html>
Well the problem is that the text box at the bottom doesnt change when i select something else, could someone help please?
Xyzer is offline  
Old 02-19-2006, 09:36 AM   #6 (permalink)
NamePros Member
 
Join Date: Feb 2006
Location: Chicago IL
Posts: 73
25.00 NP$ (Donate)

AllValley is an unknown quantity at this point


Correct it as per the advice in my last post, and it works. But I'll leave that to you.
Cannot learn without doing

Also, I see no text box :s
__________________
Hassle Free Computing and Web Solutions for Personal and Business!
Rochelle Network Communications!
AllValley is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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


Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 01:33 AM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85