View Single Post
  #5 (permalink)  
Old Dec 22nd, 2006, 15:52
josephman1988 josephman1988 is offline
Junior Member
Join Date: Dec 2006
Location: London
Age: 20
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Automatic calculations

Oh, apologies.

What i mean by 'messing up' is:

Although the code provided does work in terms of calculating the value, when i try to add another dropdown box, i believed that adding the simple code to both:

javascript:

Code: Select all
function formCalc() {
    var musicquantity = document.getElementById('musicquantity').value;
    var musicprice = document.getElementById('musicprice').value;
    document.getElementById('total').value = musicquantity * musicprice;
}
HTML:

HTML: Select all
<strong><u>Pictures</u></strong>
<select onchange="formCalc();" id="musicquantity">
<option value="0">None</option>
<option value="1">1 Song</option>
<option value="2">2 Songs</option>
<option value="3">3 Songs</option>
 
</select>
 
<input type="hidden" id="musicprice" value="3.95" onBlur="formCalc();" />
The end value ends up either Nan, or doesnt show up at all.

Last edited by josephman1988; Dec 22nd, 2006 at 15:57.
Reply With Quote