Guest_imported
New member
- Jan 1, 1970
- 0
I am trying to make a javascript that calculates an estimate for my clients. What I am doing is I have a form, and I have no problem converting the form input to strings, but once I have them as strings, when I add them, it LITERALLY adds them. Example:
variableone = document.form.formfield.value (this works fine)
variabletwo = document.form.formfield2.value (this works fine)
Next I declare a new variable equalling 0:
totalcost = 0;
but when I add the first two together:
(assuming that variableone calculates as 1 and that variabletwo calculates to 2 from the user input)
I put:
totalcost = variableone + variabletwo3
alert("The total cost is "+totalcost+" ."
but instead of alerting "3" and adding the string intergers, it comes up with "12" becasue its LITERALLY adding the two together.
If this was too confusing, email me at jeffmorrison@att.net and I'll upload the page so you can look at my source.
Thanks!!!
variableone = document.form.formfield.value (this works fine)
variabletwo = document.form.formfield2.value (this works fine)
Next I declare a new variable equalling 0:
totalcost = 0;
but when I add the first two together:
(assuming that variableone calculates as 1 and that variabletwo calculates to 2 from the user input)
I put:
totalcost = variableone + variabletwo3
alert("The total cost is "+totalcost+" ."
but instead of alerting "3" and adding the string intergers, it comes up with "12" becasue its LITERALLY adding the two together.
If this was too confusing, email me at jeffmorrison@att.net and I'll upload the page so you can look at my source.
Thanks!!!