Results 1 to 1 of 1

Thread: enable a quantity for some items and remove the global quantity

  1. #1
    Join Date
    Mar 2016
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default enable a quantity for some items and remove the global quantity

    im using this code for this page http://ariosvml.wix.com/depositos#!colombia/c24vq

    Its working, but how can i enable a quantity for some items and remove the global quantity?

    This is the code

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <!-- Paste this code into an external JavaScript file (remove the opening and closing <script> tags) -->
    
    <script type="text/javascript">
    /* This script and many more are available free online at
    The JavaScript Source :: http://javascript.internet.com
    Created by: Kevin Hartig :: http://www.grafikfx.net/ */
    
    // Calculate the total for items in the form which are selected.
    function calculateTotal(inputItem) {
    	var calculatedTotal = multiplier = i = 0, form = inputItem.form, els = form.elements, tot;
    	for(i; i < els.length; ++i){
    		if (els[i].type === "checkbox" && els[i].checked) {
    			calculatedTotal += +els[i].value;
    			++multiplier;
    		} else if (els[i].type === "radio" && els[i].checked) {
    			calculatedTotal += els[i].value * (multiplier || 1);
    		}
    	}
    	calculatedTotal *= form.quantity.value;
    	
    	// Total value should never be less than 0.
    	if (calculatedTotal < 0) {
    		InitForm();
    		return;
    	}
    	
    	// Set total field(s) to total value.
    	tot = formatCurrency(calculatedTotal);
    	for (i = form.total.length - 1; i > -1; --i){
    		form.total[i].value = tot;
    	}
    }
    
    // Format a value as currency.
    function formatCurrency(num) {
      num = num.toString(10).replace(/[$,]/g,'');
      if(isNaN(num)){num = 0;}
      return ((num == (num = Math.abs(num))?'':'-') + '$' + num.toFixed(0));
    }
    
    // This function initialzes all the form elements to default values.
    function InitForm(form) {
      // Reset values on form.
      var tots = form.total, els = form.elements;
      for (var i = tots.length - 1; i > -1; --i){
        tots[i].value = '$0';
      }
    
      // Set all checkboxes and radio buttons on form to unchecked.
      for (i = els.length - 1; i > -1; --i){
        if (els[i].checked) {
          els[i].checked = false;
        } else if (els[i].tagName.toLowerCase() === 'select'){
          els[i].options.selectedIndex = 0;
        }
      }
    }
    </script>
    
    <!-- Paste this code into the HEAD section of your HTML document
         Change the file name and path to match the one you created
    
    <script type="text/javascript" src="yourFileName.js"></script>  -->
    <style type="text/css">
    form {
    	font: normal 90% verdana, helvetica, arial, sans-serif;
    }
    fieldset, legend {
    	border: 2px solid #aaa;
    	border-radius: 7px;	
    }
    legend {
    	padding: 3px 5px;
    	font-weight: bold;
    	font-size: 90%;
    }
    form b {
    	font-size: 110%;
    }
    </style>
    </head>
    <body>
    
    <!-- Paste this code into the BODY section of your HTML document  -->
    
    <div style="width: 430px; margin: auto;">
      <form method="post" name="selectionForm">
        <b>MyCraft Colombia</b><br><br>
    <fieldset><legend>Rangos Generales</legend><br>
    
        &nbsp;&nbsp;<label><input type="checkbox" name="vip" value="10000"> VIP 1 mes $10000</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="vip+" value="17500"> VIP+ 1 mes $17500</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="platinum" value="27500"> Platinum 1 mes $27500</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="elite" value="37500"> Elite 1 mes $37500</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="paqueteelite" value="40000"> Paquete Platinum 40 dias $40000</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="paqueteplatinum" value="52500"> Paquete Elite 40 dias $52500</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="vip3" value="28000"> VIP 3 meses $28000</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="vip+3" value="45500"> VIP+ 3 meses $45500</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="platinum3" value="68700"> Platinum 3 meses $68700</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="elite3" value="89900"> Elite 3 meses $89900</label>
        <br><br>
        <strong>Total:</strong>
        <input type="text" name="total" readonly>
    </fieldset>
    
        <br><br>
    <fieldset><legend>Survival 1.7:</legend><br>
        <legend>Armas RPG:</legend><br>
        &nbsp;&nbsp;<label><input type="checkbox" name="packrpgsurvival1.7" value="15000"> Pack de Armas $15000</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="venganzaquetzalcoatl1.7" value="8700"> Venganza de Quetzalcoatl + 15 Gemas $8700</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="ozmictlan1.7" value="10000"> Oz de Mictlan + 40 Gemas $10000</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="packhachas1.7" value="12500"> Pack de Hachas + 20 Gemas $12500</label>
        <br>
        &nbsp;&nbsp;<label><input type="checkbox" name="palogolpeador1.7" value="10000"> Palo Golpeador de Parejas Felices $10000</label>
        <br><br>
        <strong>Total:</strong>
        <input type="text" name="total" readonly>
    </fieldset>
    
        <br><br>
    <fieldset><legend>Cantidad</legend>
      <select name="quantity">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      </select>
    </fieldset>
        <br><br>
        <strong>Pasos para Depositar:</strong><br><br>
    
        <span style="font: normal 16px arial, helvetica, sans-serif;">
    	1. Dirigete al efecty mas cercano<br><br>
        2. Menciona al cajero que haras un deposito de:<br><br>
        <div style="text-align: center;">
        <strong>Monto:</strong>
        <input type="text" name="total" readonly>&nbsp;pesos&nbsp;
        <input type="reset"><br><br>
        al numero de cedula <strong>94541381</strong> a nombre de<br>
        <strong>Alexy Jair Cruz Peņa</strong>
        </div><br><br>
        3. Manda un correo a depositos.mycraft@hotmail.com con los siguientes datos:<br><br>
        &nbsp;&nbsp;&nbsp;&nbsp; - Nick<br>
        &nbsp;&nbsp;&nbsp;&nbsp; - Fecha de Deposito<br>
        &nbsp;&nbsp;&nbsp;&nbsp; - Items Comprados<br>
        &nbsp;&nbsp;&nbsp;&nbsp; - Monto de depositado<br>
        &nbsp;&nbsp;&nbsp;&nbsp; - Foto del recibo o ticket (No Obligatorio)<br><br>
        <div style="text-align: center;"><strong>Si mandas foto del ticket tu pago se procesara mas rapido</strong></div><br><br>
        4. Tu pago se procesara de 12 a 24 hrs<br><br>
        <div style="text-align: center;"><strong>Atencion: Si no tienes correo tambien puedes mandar estos datos a nuestro whatsapp +5215527699969</strong></div><br><br>
        </span>
    
      </form>
    </div>
    <p><div style="text-align: center;">
    <span style="font: normal 10px arial, helvetica, sans-serif;">Free JavaScripts provided<br>
    by <a href="http://javascriptsource.com">The JavaScript Source</a></span>
    </div><p>
    <script type="text/javascript">
    (function(){
    	var form = document.forms.selectionForm, puts = form.elements;
    	InitForm(form);
    	form.onreset = function(){InitForm(this); return false;};
    	for (var i = puts.length - 1; i > -1; --i){
    		if(/radio|checkbox/.test(puts[i].type)){
    			puts[i].onclick = function(){calculateTotal(this);};
    		} else if (puts[i].name === 'quantity') {
    			puts[i].onchange = function(){calculateTotal(this);};
    		} else if (puts[i].name === 'total') {
    			puts[i].onfocus = function(){this.blur();};
    		}
    	}
    })();
    </script>
    </body>
    </html>
    Regards,
    Last edited by jscheuer1; 04-28-2016 at 03:54 PM. Reason: format link

Similar Threads

  1. Replies: 5
    Last Post: 11-15-2011, 09:30 PM
  2. JavaScript display quantity help
    By desmond_ckl in forum JavaScript
    Replies: 0
    Last Post: 10-20-2011, 07:21 AM
  3. Get price via quantity field
    By gwmbox in forum JavaScript
    Replies: 1
    Last Post: 01-07-2011, 11:16 AM
  4. Decrease quantity as used
    By cindybrock61 in forum Other
    Replies: 2
    Last Post: 10-30-2009, 09:46 AM
  5. Replies: 2
    Last Post: 07-16-2008, 10:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •