Values not adding


I am getting some numeric values entered by users in textbox and need to sum them up.

I am getting the values fine from text box but when I do:

var total = baseprice + metal + colour;

Then instead of summing them up it shows me: 1002030 where as it should be: 150

How to do ?


Here’s my code:


<script language="javascript">
function updprice()
        var baseprice = document.f1.ItemPrice.value;
        var metal = document.f1.metal.value.split("|");
        var colour = document.f1.colour.value.split("|");
        var clarity = document.f1.clarity.value.split("|");
        var ringsize = document.f1.ringsize.value.split("|");

        var total = baseprice + metal[0] + colour[0] + clarity[0] + ringsize[0]; = total;

<form method="post" action="add.php" name="f1">
Base Price: <input type="text" name="ItemPrice" value="100"><br />
<br />
<select name="metal" id="metal" onchange="updprice()">
        <option value="">Select...</option>
        <option value="10|9ct Yellow Gold">9ct Yellow Gold</option>
        <option value="20|9ct White Gold">9ct White Gold</option>
        <option value="30|18ct Yellow Gold">18ct Yellow Gold</option>
</select><br />
<br />
<select name="colour" id="colour" onchange="updprice()">
        <option value="">Select...</option>
        <option value="10|D/E/F">D/E/F</option>
        <option value="20|H/G">H/G</option>
        <option value="30|I/J">I/J</option>
</select><br />
<br />
<select name="clarity" id="clarity" onchange="updprice()">
        <option value="">Select...</option>
        <option value="10|VVS">VVS</option>
        <option value="20|VS">VS</option>
        <option value="30|SI">SI</option>
</select><br />
<br />
Ring Size:
<select name="ringsize" id="ringsize" onchange="updprice()">
        <option value="">Select...</option>
        <option value="10|H">H</option>
        <option value="20|I">I</option>
        <option value="30|J">J</option>
</select><br />
<br />
Total: &pound;<input type="text" name="total" id="total" value="0" style="border:0px;" />

Please help.



Nevermind i got it. It was simple. I had to put all variable in a function called Number().

Please keep in mind that N of Number should be capital else it won’t work.