|
parseInt Output Trouble
Hey. I need some javascript help. Quite confused. So I made a .js file with the following contents.
function cost (){
var q = "How much do you want to spend for a Hotel?"
var newb1 = prompt(q, "")
var q = "How much do you want to spend for Food?"
var newb2 = prompt(q, "")
var q = "How much do you want to spend for Activities?"
var newb3 = prompt(q, "")
var q = "How much for Shopping?"
var newb4 = prompt(q, "")
sum2 = parseInt(newb1) + parseInt(newb3) + parseInt(newb4)
document.getElementById("cost").innerHTML = "Total Price :" +sum2
}
Then I inserted it into my homepage using this.
<script type="text/javascript" src="hotelprice.js"></script>
The prompt comes up, asks for all of the inputs. But it doesn't display the output, which should have simply added them all together. How do I fix this?
|