Conor
New Member
- Messages
- 3,570
- Reaction score
- 0
- Points
- 0
Hey guys,
I'm a total beginner in Javascript and I need help! I have an assignment due tomorrow and I can't get this figured out! I'll try to break it down for you as best I can.
The goal: When the 'Process' button is clicked, the inputted 'Price' multiplies by the number of items inputted and puts that value into the Sale Value field. It also adds the sale value to the Customer Total field value and increases the 'Items Purchased' field value by 1.
Here's all of my code.
My HTML should be more or less right on, but I have no idea with the Javascript. Please help!
I'm a total beginner in Javascript and I need help! I have an assignment due tomorrow and I can't get this figured out! I'll try to break it down for you as best I can.
The goal: When the 'Process' button is clicked, the inputted 'Price' multiplies by the number of items inputted and puts that value into the Sale Value field. It also adds the sale value to the Customer Total field value and increases the 'Items Purchased' field value by 1.
Here's all of my code.
Code:
<html>
<head>
<title>Assignment 5</title>
<script type="javascript">
function process(price, number)
{
var value = document.form.price.value * document.form.number.value;
document.form.salevalue.value = document.form.price.value * document.form.number.value;
document.form.customertotal.value = document.form.salevalue.value + value;
document.form.itemnumber.value = document.form.itemnumber.value + 1;
}
</script>
</head>
<body>
<p><b><u>East Residence Online Organic Store</u></b></p>
<br>
<table border="1" width="400">
<form name="form">
<tr>
<td><b>Customer Number</b>
<input type="text" name="customernumber" value="1" />
</td>
<td><b>Home delivery</b>
<input type="checkbox" name="homedelivery" value="Home" checked />
</td>
</tr>
<tr>
<td><b>Items purchased</b></td>
<td>
<input type="text" name="itemspurchased" />
</td>
</tr>
<tr>
<td><b>Item number</b></td>
<td>
<input type="text" name="itemnumber" value="1" />
</td>
</tr>
<tr>
<td><b>Price</b></td>
<td>
<input type="text" name="price" />
</td>
</tr>
<tr>
<td><b>Number</b></td>
<td>
<input type="text" name="number" />
</td>
</tr>
<tr>
<td><b>Value of sale</b></td>
<td>
<input type="text" name="salevalue" value="0" />
</td>
</tr>
<tr>
<td><b>Customer Total</b></td>
<td>
<input type="text" name="customertotal" value="0" />
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="button" name="Process" value="Process" onclick=" process()" />
</td>
</tr>
</form>
</table>
</body>
</html>
My HTML should be more or less right on, but I have no idea with the Javascript. Please help!