#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0

    Pizza ordering project, a minute of help please. urget


    hi guys, if u can help me i would be glad so much, its final day and i have a project i need to send, though i have stucked in 1 simple problem.

    i have a pizza online order project, basically u choose what pizza u want , how many and u can see the price in the end. the problem i face is that when i choose more than one pizza, the total price isn't changed, and it remains to one pizza's price. You can see the code below, please help me if u can guys..

    this is the code



    Code:
    <html>
    
    
    	<head>
    		
    		<meta http-equiv="Content-Type"
    		content="text/html; charset=iso-8859-7">
          </script>
    		
    <SCRIPT LANGUAGE="JavaScript">
    
    var list=new Array();
    var i=0;
    
    
    
    
    function fasi(){
    
    	var price1=7.99;
    	var price2=0;
    	
    	if(document.form.type.value=="Margarita")price1=6.99;
    	if(document.form.type.value=="Classic")price1=8.99;
    	
    	if(document.form.sidide.value=="Medium")price2=2;
    	if(document.form.sidide.value=="Large")price2=3;
    	
    	var total=(price1+price2)*1.23;
    	total=Math.ceil(total * 100) / 100 ;
    	document.form.soul.value=total;
    	
    	
    	
    	
    	
    }
    
    function order(){
    	
    list[i]=new Object();
    list[i].type=document.form.type.value;
    list[i].quan=document.form.quan.value;
    list[i].crus=document.form.crus.value;
    list[i].sidide=document.form.sidide.value;
    list[i].namesr=document.form.namesr.value;
    list[i].address=document.form.address.value;
    list[i].soul=document.form.soul.value;
    i++;
    
    content();
    
    
    }
    
    function cancel(){
    
    
    
    list.splice(0,i);
    i=0;
    content();
    
    }
    function content(){
    
    document.form.adds.value = "";
    for(var b=1;b<i;b++){
    	addtext(b+")  "+list[b].type+", "+list[b].quan+", "+list[b].crus+" "+list[b].sidide+", "+list[b].namesr+", "+list[b].address+" ->"+" "+list[b].soul+" Ευρώ \n");
    }
    
    if(i==0){
    		document.getElementById("olaboum").disabled =true;
    		document.getElementById("ade geia").disabled =true;
    	}
    if(i!=0){
    		document.getElementById("olaboum").disabled=false;
    		document.getElementById("ade geia").disabled =false;
    	}
    
    
    }
    
    
    function addtext(add) {
    
    
    	
    	document.form.adds.value += add;
    	
    
    
    
    }
    
    function deletacione(){
    
    var id=document.form.idprosdiagrafi.value;
    list.splice(id,1);
    i--;
    
    content();
    
    }
    
    
    </script>
    	
    	<style type="text/css">
    	#apDiv1 {
    	position:absolute;
    	width:304px;
    	height:270px;
    	z-index:1;
    	left: 179px;
    	top: 90px;
    }
        #apDiv2 {
    	position:absolute;
    	width:200px;
    	height:115px;
    	z-index:1;
    	left: 233px;
    	top: 88px;
    }
        </style>
    	</head>
    
    	<body  background="menu-free-background.png" onLoad="fasi();">
    	
    		<form name="form">
    		
    		<div class="class1">
    		  <p>&nbsp;</p>
    		  <p><br>
    	      </p>
            </div>
    				
    		<div class="stiqueeeeee">
    		
    	
    		<div class="stique">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type of pizza:
    		  <select name="type" id="type" onChange="fasi();">
    		    <option value="Margarita">Margarita</option>
    		    <option value="Bacon">Bacon</option>
    		    <option value="Vegetarian">Vegetarian</option>
    		    <option value="Classic">Classic</option>
    	      </select>
    		  <p>
    	   &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Quantity:
    	    <input size="15" type="text" name="quan" id="quan">
    	    <p>
    		 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &Kappa;&rho;&omicron;ύ&sigma;&tau;&alpha;:
    <select name="crus" id="crus">
    	    <option value="λεπτή" selected>Λεπτή</option>
    		    <option value="χοντρή">Χοντρή</option>
    		    <option value="Κλασσική">Κλασσική</option>
            </select>
    		  <p>
    		  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;size:
              <select name="sidide" id="sidide" onChange="fasi();">
    	    <option value="Small">Small</option>
    	    <option value="Medium" selected>Medium</option>
    		    <option value="Large">Large</option>
    	      </select>
    		  <p>
    		  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name:
              <input name="namesr" type="text" id="namesr" size="25">
    		  <p>
    		  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;address :
              <input name="address" type="text" id="address" size="35">
    		  <p>
    		  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Total price:
              <input name="soul" type="text" disabled id="soul" size="5">
              &euro;
    		  <p>          
    		  <p></div>
    <p>&nbsp;</p>
    </div>
    		<div class="adds">
    		  <textarea id="adds" name="adds" rows="10" cols="80" wrap="off" disabled>
    			 
    		  </textarea>
    		</div>
    			
    	
    		<div class="troll">
    <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="Submit"  onclick="order();"> 
    			  <input name="deletecioneduo" id="deletecioneduo" type="button" value="Delete all" onClick="cancel();">
    		  </p>
    		  <p>&nbsp;</p>
    		</div>
    		
    		
    		
    		<div class="braton">
    			
    			  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input name="ade geia" id="ade geia" type="button" value="Delete specific number" onClick="deletacione(document.form.idprosdiagrafi.value);">
    		  </p>
    			<p>
    			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input size="5" type="text" name="idprosdiagrafi" id="idprosdiagrafi">
    		  </p>
    			</p>
    		</div>
    		
    		
    		
    		
    		
    
    		</form>
    </body>
    
    
    </html>
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,008
    Rep Power
    2790
    Welcome to DevShed. That code is pretty awful. This should solve your immediate problem.
    Javascript Code:
    	var total=(price1+price2)*1.23;
    	total = total * parseInt(document.form.quan.value);
    	total=Math.ceil(total * 100) / 100 ;
    	document.form.soul.value=total;

    Comments on this post

    • Edge360 agrees
    [PHP] | [Perl] | [Python] | [Java] != [JavaScript] | [XML] | [ANSI C] | [C++] | [LUA] | [MySQL] | [FirebirdSQL] | [PostgreSQL] | [HTML] | [XHTML] | [CSS]

    W3Fools - A W3Schools Intervention.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    50
    Rep Power
    35
    You don't seem to be using the value of quantity in your total calculation.

    You could possibly use it like this:
    Code:
    document.form.soul.value=total*document.form.quan.value;
    Although it would probably be a good idea to check that the value that has been entered into 'quan' is actually a number before using it in the calculation.

    Edit: Whoops, too late...

    Comments on this post

    • Winters agrees
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    2
    Rep Power
    0
    thank you guys, u saved me today, a huge thank you

IMN logo majestic logo threadwatch logo seochat tools logo