Dynamically populate text field based on dropdown box value inColdfusion

L

Lewis

Hi,

I am trying to make a website for a new computer company. Part of the
website allows you to choose different componets, like the Dell
website. It has different drop downs like CPU, Case, motherboard etc
which list the option we have chosen then it gets all of the records
from each database. So for CPU it checks to see what motherboard is
selected and displays all of the CPUs that are compatible with that
board from the CPU database.

It has the price at the bottom of the page which is calculated by
adding all the prices of the drop down menus together but if I change
an option it doesn't change the price.

All of the drop downs are independant. So if a user chooses a
different motherboard it can update the price and then if they choose
a different processor it updates again etc.. just like Dell use for
their PC configurator.

How can I have the price dynamically change based on different values
being selected from the drop down boxes?

Thanks for any help

Lewis
 
S

SAM

Le 11/26/08 11:28 AM, Lewis a écrit :
Hi,

I am trying to make a website for a new computer company. Part of the
website allows you to choose different componets, like the Dell
website. It has different drop downs like CPU, Case, motherboard etc
which list the option we have chosen then it gets all of the records
from each database. So for CPU it checks to see what motherboard is
selected and displays all of the CPUs that are compatible with that
board from the CPU database.

It has the price at the bottom of the page which is calculated by
adding all the prices of the drop down menus together but if I change
an option it doesn't change the price.

How is it calculated (on server or in line ? (php? JS? Ajax?))
All of the drop downs are independant. So if a user chooses a
different motherboard it can update the price and then if they choose
a different processor it updates again etc.. just like Dell use for
their PC configurator.

How can I have the price dynamically change based on different values
being selected from the drop down boxes?

what could be a "drop down boxes" ?
couldn't you call that a 'menu' or a 'select' ?

where does the final price live ?
- in an input (text-field)
- in a text tag ? (P, DiV, ...)


<select onchange="price(this)" blah >

<h2>Total amount : <span id="price">$100.25</span></h2>

function price(what) {
var p = document.getElementById('price');
p.innerHTML = '$' + what.options[what.selectedIndex].value;
}
Thanks for any help

Now if the calculation must be made from all the drop-downs ...

<form id="choice" blah >
<select name="CM" onchange="total()" blah >
<select name="CPU" onchange="total()" blah >
<select name="Case" onchange="total()" blah >


function total() {
var f = document.getElementById('choice');
var t = 0, T = ['CM', 'CPU', 'Case'], n = T.length;
for(var i=0; i<n; i++) {
var o = f.elements[T];
if(typeof o !='undefined')
t += o.options[o.selectedIndex].value*1;
}
t = t+'';
if (t.indexOf('.')<0) t = t + '.00';
while (t.substring(t.indexOf('.')).length<3) t += '0';
document.getElementById('price').innerHTML = '$' + t;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top