3 Replies - 419 Views - Last Post: 17 March 2012 - 02:55 AM

#1 admjhosef  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 42
  • Joined: 02-October 10

negative value in Total

Posted 16 March 2012 - 03:52 PM

im having a trouble in this code

when i add the pencil 55 and ballpen 120

the total is 175

then when i remove

the pencil the total is -10 it suppose to be 120 the total then when i remove again the ballpen it will be -130 the total suppose to be 0

when i put the pencil 55 and ball pen 120 again


when i remove the ballpen 1st the total is 55 then when i remove the pencil is -65

it suppose to be 0

HELP... thanks in advance

this the code

in HTML

<html>
		<head>
			<link rel="stylesheet" type="text/css" href="external.css"/>
			<title>
				AMF / Aldric's
			</title>
				<script language="javascript" style = "text/javascript" src = "budget.js"></SCRIPT>
	<script language="javascript" style = "text/javascript" src = "showhide.js"></SCRIPT>
		</head>


<BODY>
<center>
<table width=980>
				<tr>
					<td id="header"></td>
				</tr>
				
				<tr><td>
						<table width=100% align="center">
							<tr>
								<td class=navi height=35 width=190><p class="navigation"><a href="home.htm">HOME</a></p></td>
								<td class=navi height=35 width=190><p class="navigation"><a href="products.htm">PRODUCTS</a></p></td>
								<td class=navi height=35 width=190><p class="navigation"><a href="whatsnew.htm">WHAT'S NEW?</a></p></td>
								<td class=navi height=35 width=190><p class="navigation"><a href="aboutus.htm">ABOUT US</a></p></td>
								<td class=navi height=35 width=190><p class="navigation"><a href="developers.htm">DEVELOPERS</a></p></td>
							</tr>
						
						</table>
					</td>
				</tr>
</table>

<FORM name=oform ACTION = "mailto:john_joseph_paragua@yahoo.com" method = "post" enctype="text/plain">
<table width=980 height=600 >
								<td height=590 width=140>
									
										PRODUCTS: <br>
										<a href = " #" onclick = "show_SchoolSupplies()">School Supplies</a> <br>
										<a href = " #" onclick = "show_toys()">Toys</a><br>
										<a href = " #" onclick ="show_FashionAccessories()">Fashion Accessories</a><br>
										<a href = " #" onclick = "show_CPAccessories()">Cellphone Accessories</a> <br>
										<a href = " #" onclick = "show_GameCards()">Game Cards</a> <br>				 
									
								</td>
								<td width=480>
									<div id="SchoolSupplies">
									<table cellpadding="2" height=590 class=prod_table>
										
											<tr>
												<h1>School Supplies</h1>											
												<td><p>Pencil/box</p>
													<INPUT TYPE="TEST" name="product" value = "Pencil/box" disabled = "disabled" style="WIDTH: 1px; HEIGHT: 0px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value1" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value1'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value1'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "55" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(0)" VALUE="Add Item">
												</td>											
												
												<td><p>Intermediate Pad/Bundle</p>
													<INPUT TYPE="TEST" name="product" value = "Intermediate Pad/Bundle" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value2" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value2'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value2'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "120" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(1)" VALUE="Add Item" name = "Add">
												</td>								
												
												<td><p>Ballpen/Box</p>
													<INPUT TYPE="TEST" name="product" value = "Ballpen/Box" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value3" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value3'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value3'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "72" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(2)" VALUE="Add Item" name = "Add">
												</td>								
												
												<td><p>Notebook/Dozen</p>
													<INPUT TYPE="TEST" name="product" value = "Notebook/Dozen" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value4" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value4'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value4'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "120" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(3)" VALUE="Add Item">
												</td>								
												
												<td><p>Crayons 24 colors/box</p>
													<INPUT TYPE="TEST" name="product" value = "Crayons/box" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value5" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value5'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value5'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "250" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(4)" VALUE="Add Item">
												</td>							
											</tr>
										</div>
									</table>
								
									
									<div id="Toys">	
										<table cellpadding="3" height=590 class=prod_table>
											
											<tr>
											<h1>Toys</h1>
												<td><p>Robot/Dozen</p>
													<INPUT TYPE="TEST" name="product" value = "Pencil/box" disabled = "disabled" style="WIDTH: 1px; HEIGHT: 0px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value1" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value1'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value1'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "90" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(0)" VALUE="Add Item">
												</td>											
												
												<td><p>Pellet Gun/Piece</p>
													<INPUT TYPE="TEST" name="product" value = "Pellet Gun/Piece" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value2" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value2'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value2'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "150" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(1)" VALUE="Add Item" name = "Add">
												</td>								
												
												<td><p>Stuffed Toys/Piece</p>
													<INPUT TYPE="TEST" name="product" value = "Stuffed Toys/Piece" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value3" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value3'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value3'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "90" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(2),this.disabled=true" VALUE="Add Item" name = "Add">
												</td>								
												
												<td><p>Barbie Dolls/Piece</p>
													<INPUT TYPE="TEST" name="product" value = "Notebook/Dozen" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value4" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value4'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value4'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "120" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(3)" VALUE="Add Item">
												</td>								
												
												<td><p>Crayons 24 colors/box</p>
													<INPUT TYPE="TEST" name="product" value = "Crayons 24 colors/box" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value5" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value5'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value5'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "250" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(4)" VALUE="Add Item">
												</td>								
											</tr>
										</table>
									</div>
										
									<div id ="FassionAccessories">
										<table cellpadding="3" height=590 class=prod_table>
											<h1>Fashion Accessories</h1>
											<tr>
												<td><p>Earrings/Dozen</p>
													<INPUT TYPE="TEST" name="product" value = "Earrings/Dozen" disabled = "disabled" style="WIDTH: 1px; HEIGHT: 0px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value11" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value11'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value11'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "120" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(11)" VALUE="Add Item">
												</td>											
												
												<td><p>Necklace/Piece</p>
													<INPUT TYPE="TEST" name="product" value = "Necklace/Dozen" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value12" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value12'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value12'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "100" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(12)" VALUE="Add Item" name = "Add">
												</td>								
												
												<td><p>Bracelets/Piece</p>
													<INPUT TYPE="TEST" name="product" value = "Bracelets/Dozen" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value13" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value13'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value13'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "50" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(13),this.disabled=true" VALUE="Add Item" name = "Add">
												</td>								
												
												<td><p>Headbands/Dozen</p>
													<INPUT TYPE="TEST" name="product" value = "Headbands/Dozen" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value14" value="0" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value14'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value14'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "150" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(14)" VALUE="Add Item">
												</td>								
												
												<td><p>Bags/Piece</p>
													<INPUT TYPE="TEST" name="product" value = "Bags/Piece" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value15" value="250" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value15'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value15'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "150" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(15)" VALUE="Add Item">
												</td>								
											</tr>
										</table>
									
									</div>	
									<div id ="CellphoneAccessories">
										<table cellpadding="3" height=590 class=prod_table>
											<h1>Cellphone Accessories</h1>
											<tr>
												<td><p>Key Chain</p>
													<INPUT TYPE="TEST" name="product" value = "Pencil/box" disabled = "disabled" style="WIDTH: 1px; HEIGHT: 0px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value1" value="80" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value1'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value1'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "55" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(0)" VALUE="Add Item">
												</td>											
												
												<td><p>Intermediate Pad/Bundle</p>
													<INPUT TYPE="TEST" name="product" value = "Intermediate Pad/Bundle" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value2" value="150" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value2'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value2'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(1)" VALUE="Add Item" name = "Add">
												</td>								
												
												<td><p>Ballpen/Box</p>
													<INPUT TYPE="TEST" name="product" value = "Ballpen/Box" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value3" value="90" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value3'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value3'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(2),this.disabled=true" VALUE="Add Item" name = "Add">
												</td>								
												
												<td><p>Notebook/Dozen</p>
													<INPUT TYPE="TEST" name="product" value = "Notebook/Dozen" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value4" value="150" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value4'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value4'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(3)" VALUE="Add Item">
												</td>								
												
												<td><p>Crayons 24/box</p>
													<INPUT TYPE="TEST" name="product" value = "Crayons/box" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value5" value="250" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value5'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value5'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(4)" VALUE="Add Item">
												</td>								
											</tr>
										</table>
									</div>
									<div  id="gamecards">
										
										
										<table cellpadding="3" height=590 class=prod_table>
											<h1>Game Cards</h1>
											<tr>
												<td><p>MU Philippines</p>
													<INPUT TYPE="TEST" name="product" value = "MU Philippines" disabled = "disabled" style="WIDTH: 1px; HEIGHT: 0px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value21" value="80" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value21'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value21'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" value = "55" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(21)" VALUE="Add Item">
												</td>											
												
												<td><p>Get Amped</p>
													<INPUT TYPE="TEST" name="product" value = "Get Amped" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value22" value="150" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value22'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value22'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(22)" VALUE="Add Item" name = "Add">
												</td>								
												
												<td><p>Level Up!</p>
													<INPUT TYPE="TEST" name="product" value = "Level Up!" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value23" value="90" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value23'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value23'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(23),this.disabled=true" VALUE="Add Item" name = "Add">
												</td>								
												
												<td><p>Cherry De Games Credit</p>
													<INPUT TYPE="TEST" name="product" value = "Cherry De Games Credit" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value24" value="150" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value24'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value24'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(24)" VALUE="Add Item">
												</td>								
												
												<td><p>Garena</p>
													<INPUT TYPE="TEST" name="product" value = "Crayons/box" disabled = "disabled" style="WIDTH: 80px; HEIGHT: 22px; text-align:center; visibility:hidden"><br>
													Quantity
													<INPUT TYPE="TEST" name="quantity" id="value25" value="250" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled"><br>
													<input type = "button" value = "+" onclick = "compute('add', document.getElementById('value25'))">
													<input type = "button" value = "-" onclick = "compute('sub', document.getElementById('value25'))"><br>
													Price
													<INPUT TYPE="TEST" name="price" style="WIDTH: 60px; HEIGHT: 22px; text-align:center" disabled = "disabled">
													<INPUT TYPE=button onclick="AddItem(25)" VALUE="Add Item">
												</td>							
											</tr>
										</table>
									</div>			
								</td>

	
								<td width=280 height=590><form name=pass >
								
								<SELECT NAME="Products_Item" MULTIPLE  STYLE="width:100%; height:250px;text-align:center"></SELECT>
									
								TOTAL: <input type="text" name=Total disabled = "disabled"><INPUT TYPE=button onclick="UnPopulate()" VALUE="Remove" ><br>
								<fieldset>
								<legend>Personal Form:</legend>
									<center>Name: <input type = "text" name = "CustomerName" STYLE = "	width: 300px"><br>
									Email Address:<br> <input type = "text" name = "CustomerEAdd" STYLE = "	width: 300px"><br>
									Contact Number:<br> <input type = "text" name = "ContactNumber" STYLE = "	width: 300px"><br>
									Mode of Payment: <br>
									<input type = "radio" name = "ModePayment" Value = "PickUp" onclick = "able_disable()" checked>Pick Up <br>
									<input type = "radio" name = "ModePayment" Value = "Deliver" onclick = "able_disable()">Delivery <br>
									Address: <input type = "text" name = "CustomerAddress" disabled = "disabled" STYLE = "	width: 300px"><br>
									Smart Money ref#: <input type = "text" name = "Refnum" disabled = "disabled" STYLE = "	width: 300px"></center>
									<br>
									<input type="submit" name="submit" value="Submit" onclick="selectall()"></form>
									</fieldset>
									 
									

								</td>
							</table>
</FORM>
</center>
</BODY>
</html>



the code in Java script

		var add = new Array;
		var sub = new Array;
		var bilang=0;
		var frm;
		var field1;
		var field2;
		var x =0;
		var Ftotal = 0;
		var total;
		
		function compute(ope, element)
		{
			document.oform.quantity.value=bilang;
			var bilang=element.value;
			
			if(ope == "add")
			{
				bilang++;
				element.value=bilang;
			}
			else if(ope == "sub")
			{
				if (bilang == 0)
				{
					element.value=0;
				}
				else{
					bilang--;
					element.value=bilang;
				}
			}
		}
		
		

		function isNumberKey(evt)
		{
			var charCode = (evt.which) ? evt.which : event.keyCode
			if (charCode > 31 && (charCode < 48 || charCode > 57))
			return false;
			return true;
		}

		function UnPopulate() 
		{
		  var t = field2.length-1;  
		  for(i=t; i>=0; i--) 
		  {
			if (field2.options[i].selected) 
			{
				 field2.options[i] = null;  
				Ftotal -= total;
			document.oform.Total.value = Ftotal;
		
			}
		
		  }
		}


		function AddItem(N) 
		{
			if(document.oform.quantity[N].value == 0)
			{
			  alert("Please Put some Quantity in " + document.oform.product[N].value);
			}
			else
			{
			  var l = field2.length;
			  newOpt=document.oform.product[N].value;
			  newOpt1=document.oform.quantity[N].value;
			  newOpt2=document.oform.price[N].value;
			  total = newOpt1 * newOpt2;
			  Ftotal += total;
			  field2.options[l] = new Option(newOpt+" X " + newOpt1+ " = " +  total);
			  document.oform.Total.value = Ftotal;
			  x++;
			}
		}

		window.onload = function() {
		  frm=document.oform;
		  field1=frm.Product_Item;
		  field2=frm.Products_Item;
		}
		
		function able_disable()
		{
			var val = 0;
			for( i = 0; i < document.oform.ModePayment.length; i++ )
			{
				if( document.oform.ModePayment[i].checked == true )
				{
					val = document.oform.ModePayment[i].value;
					if(val=='Deliver')
					{
						document.oform.CustomerAddress.disabled=false;
						document.oform.Refnum.disabled=false;
						document.oform.CustomerAddress.focus();
					}
					else
					{
						document.oform.CustomerAddress.disabled=true;
						document.oform.Refnum.disabled=true;
					}
				}
			}
		}
		
		function selectall() 
		{
			if (document.oform.CustomerName.value == "")
			{
				alert("Please Fill the Customer Name");
				document.oform.CustomerName.focus();
			}
			else if (document.oform.CustomerEAdd.value == "")
			{
				alert("Please Fill the Email Address");
				document.oform.CustomerEAdd.focus();
			}
			else if (document.oform.ContactNumber.value == "")
			{
				alert("Please Fill the Contact Number");
				document.oform.ContactNumber.focus();
			}
			else
			{
			for( i = 0; i <= document.oform.Products_Item.length; i++ )
			{
				field2.options[i].selected = true;
			}
			}
		}
			
				function show_toys()
		{
				document.getElementById('Toys').style.visibility = "visible";
				document.getElementById('SchoolSupplies').style.visibility = "hidden";
				document.getElementById('FassionAccessories').style.visibility = "hidden";
				document.getElementById('CellphoneAccessories').style.visibility = "hidden";
				document.getElementById('gamecards').style.visibility = "hidden"; 
		}
		
		function show_SchoolSupplies()
		{
				document.getElementById('Toys').style.visibility = "hidden";
				document.getElementById('SchoolSupplies').style.visibility = "visible";
				document.getElementById('FassionAccessories').style.visibility = "hidden";
				document.getElementById('CellphoneAccessories').style.visibility = "hidden";
				document.getElementById('gamecards').style.visibility = "hidden";
		}

		function show_FashionAccessories()
		{
				document.getElementById('Toys').style.visibility = "hidden";
				document.getElementById('SchoolSupplies').style.visibility = "hidden";
				document.getElementById('FassionAccessories').style.visibility = "visible";
				document.getElementById('CellphoneAccessories').style.visibility = "hidden";
				document.getElementById('gamecards').style.visibility = "hidden";
		}

		function show_CPAccessories()
		{
				
				document.getElementById('Toys').style.visibility = "hidden";
				document.getElementById('SchoolSupplies').style.visibility = "hidden";
				document.getElementById('FassionAccessories').style.visibility = "hidden";
				document.getElementById('CellphoneAccessories').style.visibility = "visible";
				document.getElementById('gamecards').style.visibility = "hidden";
		}

		function show_GameCards()
		{
				document.getElementById('Toys').style.visibility = "hidden";
				document.getElementById('SchoolSupplies').style.visibility = "hidden";
				document.getElementById('FassionAccessories').style.visibility = "hidden";
				document.getElementById('CellphoneAccessories').style.visibility = "hidden";
				document.getElementById('gamecards').style.visibility = "visible";
		}

	



Is This A Good Question/Topic? 0
  • +

Replies To: negative value in Total

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3577
  • View blog
  • Posts: 10,442
  • Joined: 08-June 10

Re: negative value in Total

Posted 16 March 2012 - 04:45 PM

first, "test" is not a valid type for an input element.

second, AddItem() is given multiple times for the same number. some of these are copy/pasted wrongly (pencil box under key chain & robot dozen, crayons under cell phone accessories). a lot of indices are missing (5 - 10, 15 - 19).

third, document.oform.quantity is a HTMLCollection (list of elements). i.e. it does not have a value property.
Was This Post Helpful? 0
  • +
  • -

#3 admjhosef  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 42
  • Joined: 02-October 10

Re: negative value in Total

Posted 16 March 2012 - 08:35 PM

how can i do
in this third?

third, document.oform.quantity is a HTMLCollection (list of elements). i.e. it does not have a value property.
Was This Post Helpful? 0
  • +
  • -

#4 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3577
  • View blog
  • Posts: 10,442
  • Joined: 08-June 10

Re: negative value in Total

Posted 17 March 2012 - 02:55 AM

choose the appropriate element from that collection.
// accessing the 3rd quantity field
document.oform.quantity[2].value

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1