SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trying to dissalow "0"'s

    I'm trying to make it so that if a user types "0" into into one of the "PROD" text fileds it alerts "Please input a number greater then 0". Anyone got any ideas how to do that?

    Code JavaScript:
    <?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
     
     
    <html>
    <head>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
     
    /* This script is Copyright (c) Paul McFedries and 
    Logophilia Limited ([url]http://www.mcfedries.com/)[/url].
    Permission is granted to use this script as long as 
    this Copyright notice remains in place.*/
     
    function CalculateTotal(frm) {
        var order_total = 0
     
        // Run through all the form fields
        for (var i=0; i < frm.elements.length; ++i) {
     
            // Get the current field
            form_field = frm.elements[i]
     
            // Get the field's name
            form_name = form_field.name
     
            // Is it a "product" field?
            if (form_name.substring(0,4) == "PROD") {
     
                // If so, extract the price from the name
                item_price = parseFloat(form_name.substring(form_name.lastIndexOf("_") + 1))
     
                // Get the quantity
                item_quantity = parseInt(form_field.value)
     
                // Update the order total
                if (item_quantity >= 0) {
                    order_total += item_quantity * item_price
                }
            }
        }
     
        // Display the total rounded to two decimal places
        frm.TOTAL.value = round_decimals(order_total, 2)
     
    }
     
    function round_decimals(original_number, decimals) {
        var result1 = original_number * Math.pow(10, decimals)
        var result2 = Math.round(result1)
        var result3 = result2 / Math.pow(10, decimals)
        return pad_with_zeros(result3, decimals)
    }
     
    function pad_with_zeros(rounded_value, decimal_places) {
     
        // Convert the number to a string
        var value_string = rounded_value.toString()
     
        // Locate the decimal point
        var decimal_location = value_string.indexOf(".")
     
        // Is there a decimal point?
        if (decimal_location == -1) {
     
            // If no, then all decimal places will be padded with 0s
            decimal_part_length = 0
     
            // If decimal_places is greater than zero, tack on a decimal point
            value_string += decimal_places > 0 ? "." : ""
        }
        else {
     
            // If yes, then only the extra decimal places will be padded with 0s
            decimal_part_length = value_string.length - decimal_location - 1
        }
     
        // Calculate the number of decimal places that need to be padded with 0s
        var pad_total = decimal_places - decimal_part_length
     
        if (pad_total > 0) {
     
            // Pad the string with 0s
            for (var counter = 1; counter <= pad_total; counter++) 
                value_string += "0"
            }
        return value_string
    }
     
    function validateForm()
        {
    	formObj = document.order;
    	if ((formObj.companyName.value == "") ||
    	    (formObj.contactName.value  == "") ||
    		 (formObj.contactName.value  == "") ||
    		 (formObj.phoneNumber.value  == "") ||
    	    (formObj.orderNumber.value  == "")) {
    	    alert("Please fill all the required fields.");
    	    return false;
    	}
     
     
    	else
    	    return true;
     
        }
     
     
    <!--
    function MM_reloadPage(init) {  //reloads the window if Nav4 resized
      if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
        document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
      else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true);
    //-->
    </script>
    <title>Order</title>
    </head>
     
    <body bgcolor="#000000" onload="MM_preloadImages('Images/contact1.jpg','Images/machines.jpg','Images/enquiries.jpg','Images/ourproducts.jpg','Images/ourservice.jpg','Images/coffeeorder.jpg','Images/home.jpg')">
    <div align="center"> 
      <table id="layout" border="0" cellspacing="0">
        <tbody>
          <tr> 
            <td width="200" id="tl">&nbsp;</td>
            <td id="tr" colspan="2"> <div align="right"><a href="htt/contact-us"> 
                </a><a href=contact-us"> </a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image11','','Images/contact1.jpg',1)"><img src="Images/contact2.jpg" alt="Contact Us" name="Image11" width="80" height="13" border="0" id="Image11" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image12','','Images/machines.jpg',1)"><img src="Images/machines2.jpg" alt="Machines" name="Image12" width="72" height="13" border="0" id="Image12" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image16','','Images/coffeeorder.jpg',1)"><img src="Images/coffeeorder2.jpg" alt="Coffee Order" name="Image16" width="91" height="13" border="0" id="Image16" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image13','','Images/enquiries.jpg',1)"><img src="Images/enquiries2.jpg" alt="Enquires" name="Image13" width="69" height="13" border="0" id="Image13" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image14','','Images/ourproducts.jpg',1)"><img src="Images/ourproducts2.jpg" alt="Products" name="Image14" width="93" height="13" border="0" id="Image14" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image15','','Images/ourservice.jpg',1)"><img src="Images/ourservice2.jpg" alt="Our Service" name="Image15" width="83" height="13" border="0" id="Image15" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image17','','Images/home.jpg',1)"><img src="Images/home2.jpg" alt="Home" name="Image17" width="50" height="13" border="0" id="Image17" /></a></div></td>
          </tr>
          <tr> 
            <td colspan="3" id="banner"><div id="headimg"><img src="Images/banner.jpg" width="984" height="126" /></div></td>
          </tr>
          <tr bgcolor="#000000"> 
            <td colspan="3" id="tagline"><font color="#FFFFFF" face="Monotype Corsiva">NZ 
              specalists in wholesale coffee &amp; vending</font> vending </td>
          </tr>
          <tr bgcolor="#000000"> 
            <td id="sidebar"> 
              <div align="center"><img src="Images/bean.jpg" width="200" height="300" /></div></td>
            <td width="780" id="content">
    <div id="contentbox">
    <div style=" width:778px; height:300px; overflow:auto;"> 
                  <form action="" method="post" name="order" id="order" onsubmit="return validateForm()">
                    <table width="640" height="563" border="0" align="center">
                      <tr> 
                        <td width="763" height="559"><em><font size="1"> </font></em> 
                          <table width="634" border="0" align="center" cellpadding="0" cellspacing="0">
                            <tr> 
                              <td bgcolor="#CCCCFF" id="code"><font color="#000066" size="-1">CODE</font></td>
                              <td bgcolor="#CCCCFF" id="description"><font color="#000066" size="-1">DESCRIPTION</font></td>
                              <td bgcolor="#CCCCFF" id="cups"><font color="#000066" size="-1">CUPS</font></td>
                              <td bgcolor="#CCCCFF" id="size"><font color="#000066" size="-1">SIZE</font></td>
                              <td bgcolor="#CCCCFF" id="unitprice"><font color="#000066" size="-1">PRICE</font></td>
                              <td bgcolor="#CCCCFF" id="quantity"> <div class="noprint"><font color="#000066" size="-1">QTY</font></div></td>
                            </tr>
                            <tr> 
                              <td width="99" bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">COFDARK</font></td>
                              <td width="248" bgcolor="#FFFFCC"><font color="#333333" size="-1">Beans 
                                DECO DARK</font></td>
                              <td width="116" bgcolor="#FFFFCC">150</td>
                              <td width="117" bgcolor="#FFFFCC">1kg</td>
                              <td width="83" bgcolor="#FFFFCC">$29.90</td>
                              <td width="36" bgcolor="#FFFFCC"> <div align="center"></div>
                                <div align="right">
                                  <input name="PROD_beansDecoDark_29.90" type="text" onChange="CalculateTotal(this.form)" id="beansDecoDark" size="6"/>
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td class="code"><font color="#333333" size="-2">COFDECO</font></td>
                              <td><font color="#333333" size="-1">Beans DECO</font></td>
                              <td>150</td>
                              <td>1kg</td>
                              <td>$29.90</td>
                              <td> <div align="right"> 
                                  <input name="PROD_beansDeco_29.90" type="text" id="beansDeco" onChange="CalculateTotal(this.form)" size="6" />
                                </div></td>
                            </tr>
                            <tr> 
                              <td bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">COFCOAS</font></td>
                              <td bgcolor="#FFFFCC"><font color="#333333" size="-1">COAST 
                                VENDING INSTANT</font></td>
                              <td bgcolor="#FFFFCC">500</td>
                              <td bgcolor="#FFFFCC">1kg</td>
                              <td bgcolor="#FFFFCC">$34.90</td>
                              <td bgcolor="#FFFFCC"><div align="right"> 
                                  <input name="PROD_coastVending_34.90" type="text" onChange="CalculateTotal(this.form)" id="coastVending" size="6" />
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td class="code"><font color="#333333" size="-2">CHOCOAS</font></td>
                              <td><font color="#333333" size="-1">COAST CHOCOLATE</font></td>
                              <td>75</td>
                              <td>1kg</td>
                              <td>$12.90</td>
                              <td> <div align="right"> 
                                  <input name="PROD_coastChoc_12.90" type="text" onChange="CalculateTotal(this.form)" id="coastChoc" size="6" />
                                </div></td>
                            </tr>
                            <tr> 
                              <td bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">MILKCOAS</font></td>
                              <td bgcolor="#FFFFCC"><font color="#333333" size="-1">COAST 
                                MILK GRANULE</font></td>
                              <td bgcolor="#FFFFCC">250</td>
                              <td bgcolor="#FFFFCC">1kg</td>
                              <td bgcolor="#FFFFCC">$17.90</td>
                              <td bgcolor="#FFFFCC"><div align="right"> 
                                  <input name="PROD_coastMilkGran_17.90" type="text" onChange="CalculateTotal(this.form)" id="coastMilkGran" size="6" />
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td height="22" class="code"><font color="#333333" size="-2">MIKWEST</font></td>
                              <td><font color="#333333" size="-1">WESTPRO MILK GRANULE</font></td>
                              <td>250</td>
                              <td>1kg</td>
                              <td>$17.90</td>
                              <td> <div align="right"> 
                                  <input name="PROD_westMilkGran_17.90" type="text" onChange="CalculateTotal(this.form)" id="westMilkGran" size="6" />
                                </div></td>
                            </tr>
                            <tr> 
                              <td bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">TEACOAS</font></td>
                              <td bgcolor="#FFFFCC"><font color="#333333" size="-1">COAST 
                                TEA BAGS</font></td>
                              <td bgcolor="#FFFFCC">500</td>
                              <td bgcolor="#FFFFCC">500s</td>
                              <td bgcolor="#FFFFCC">$16.90</td>
                              <td bgcolor="#FFFFCC"><div align="right"> 
                                  <input name="PROD_coastTeaBags_16.90" type="text" id="coastTeaBags" onChange="CalculateTotal(this.form)" size="6" />
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td class="code"><font color="#333333" size="-2">TEABELL</font></td>
                              <td><font color="#333333" size="-1">BELL TEA BAGS</font></td>
                              <td>500</td>
                              <td>500s</td>
                              <td>$24.90</td>
                              <td> <div align="right"> 
                                  <input name="PROD_bellTeaBags_24.90" type="text" id="bellTeaBags" onChange="CalculateTotal(this.form)" size="6" />
                                </div></td>
                            </tr>
                            <tr> 
                              <td bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">TEANEST</font></td>
                              <td bgcolor="#FFFFCC"><font color="#333333" size="-1">SOLUBLE 
                                NESTEA</font></td>
                              <td bgcolor="#FFFFCC">&nbsp;</td>
                              <td bgcolor="#FFFFCC">100gm</td>
                              <td bgcolor="#FFFFCC">$14.90</td>
                              <td bgcolor="#FFFFCC"><div align="right"> 
                                  <input name="PROD_solNesTea_14.90" type="text" onChange="CalculateTotal(this.form)" id="solNestea" size="6" />
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td class="code"><font color="#333333" size="-2">TEALEAF</font></td>
                              <td><font color="#333333" size="-1">VENDING LEAF TEA</font></td>
                              <td>280</td>
                              <td>1kg</td>
                              <td>$16.90</td>
                              <td> <div align="right"> 
                                  <input name="PROD_venLeafTea_16.90" type="text" onChange="CalculateTotal(this.form)" id="venLeafTea" size="6" />
                                </div></td>
                            </tr>
                            <tr> 
                              <td bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">SUGCAS4</font></td>
                              <td bgcolor="#FFFFCC"><font color="#333333" size="-1">SUGAR 
                                CASTOR</font></td>
                              <td bgcolor="#FFFFCC">&nbsp;</td>
                              <td bgcolor="#FFFFCC">4kg</td>
                              <td bgcolor="#FFFFCC">$10.90</td>
                              <td bgcolor="#FFFFCC"><div align="right"> 
                                  <input name="PROD_sugCast_10.90" type="text" onChange="CalculateTotal(this.form)" id="sugCast" size="6" />
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td class="code"><font color="#333333" size="-2">SUGCAS1</font></td>
                              <td><font color="#333333" size="-1">SUGAR CASTOR</font></td>
                              <td>&nbsp;</td>
                              <td>500gm</td>
                              <td>$1.70</td>
                              <td> <div align="right"> 
                                  <input name="PROD_sugCast2_1.70" type="text" onChange="CalculateTotal(this.form)" id="sugCast2" size="6" />
                                </div></td>
                            </tr>
                            <tr> 
                              <td bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">SUGSTIX</font></td>
                              <td bgcolor="#FFFFCC"><font color="#333333" size="-1">SUGAR 
                                STICKS</font></td>
                              <td bgcolor="#FFFFCC">&nbsp;</td>
                              <td bgcolor="#FFFFCC">2000</td>
                              <td bgcolor="#FFFFCC">$39.90</td>
                              <td bgcolor="#FFFFCC"><div align="right"> 
                                  <input name="PROD_sugSticks_39.90" type="text" onChange="CalculateTotal(this.form)" id="sugSticks" size="6" />
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td class="code"><font color="#333333" size="-2">SOUPCHIC</font></td>
                              <td><font color="#333333" size="-1">CHICKEN SOUP</font></td>
                              <td>75</td>
                              <td>750gm</td>
                              <td>$23.90</td>
                              <td> <div align="right"> 
                                  <input name="PROD_chickSoup_23.90" type="text" id="chickSoup" onChange="CalculateTotal(this.form)" size="6" />
                                </div></td>
                            </tr>
                            <tr> 
                              <td bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">SOUPVEG</font></td>
                              <td bgcolor="#FFFFCC"><font color="#333333" size="-1">CREME 
                                OF VEGETABLE SOUP</font></td>
                              <td bgcolor="#FFFFCC">75</td>
                              <td bgcolor="#FFFFCC">750gm</td>
                              <td bgcolor="#FFFFCC">$23.90</td>
                              <td bgcolor="#FFFFCC"><div align="right"> 
                                  <input name="PROD_vegSoup_23.90" type="text" id="vegSoup" size="6" onChange="CalculateTotal(this.form)"/>
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td class="code"><font color="#333333" size="-2">CUPPOLY</font></td>
                              <td><font color="#333333" size="-1">POLY THERMO</font></td>
                              <td>500</td>
                              <td>250ml</td>
                              <td>$29.90</td>
                              <td> <div align="right"> 
                                  <input name="PROD_polTherm_29.90" onChange="CalculateTotal(this.form)" type="text" id="polTherm" size="6" />
                                </div></td>
                            </tr>
                            <tr> 
                              <td bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">CUPVBY</font></td>
                              <td bgcolor="#FFFFCC"><font color="#333333" size="-1">VEND 
                                CUP-245ml-BY-73mm</font></td>
                              <td bgcolor="#FFFFCC">2000</td>
                              <td bgcolor="#FFFFCC">245ml</td>
                              <td bgcolor="#FFFFCC">$214.90</td>
                              <td bgcolor="#FFFFCC"><div align="right"> 
                                  <input name="PROD_vendCup_214.90" onChange="CalculateTotal(this.form)" type="text" id="vendCup" size="6" />
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td class="code"><font color="#333333" size="-2">CUPVBR</font></td>
                              <td><font color="#333333" size="-1">VEND CUP-200ml-BR-70mm</font></td>
                              <td>2000</td>
                              <td>200ml</td>
                              <td>$214.90</td>
                              <td> <div align="right"> 
                                  <input name="PROD_vendCup2_214.90" type="text" id="vendCup2" onChange="CalculateTotal(this.form)" size="6" />
                                </div></td>
                            </tr>
                            <tr> 
                              <td bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">CUPSCAF</font></td>
                              <td bgcolor="#FFFFCC"><font color="#333333" size="-1">CAFE 
                                CUP-270ml-HAN-8oz</font></td>
                              <td bgcolor="#FFFFCC">1000</td>
                              <td bgcolor="#FFFFCC">270ml</td>
                              <td bgcolor="#FFFFCC">$135.00</td>
                              <td bgcolor="#FFFFCC"><div align="right"> 
                                  <input name="PROD_cafeCup_135.00" type="text" onChange="CalculateTotal(this.form)" id="cafeCup" size="6" />
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td class="code"><font color="#333333" size="-2">LIDS</font></td>
                              <td><font color="#333333" size="-1">LIDS PE10</font></td>
                              <td>1000</td>
                              <td>&nbsp;</td>
                              <td>$124.90</td>
                              <td> <div align="right"> 
                                  <input name="PROD_lids_124.90"  onChange="CalculateTotal(this.form)" type="text" id="lids" size="6" />
                                </div></td>
                            </tr>
                            <tr> 
                              <td bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">LIDSVDES</font></td>
                              <td bgcolor="#FFFFCC" class="description"><font color="#333333" size="-1">VENDING 
                                CUP LIDS 245ml</font></td>
                              <td bgcolor="#FFFFCC">1000</td>
                              <td bgcolor="#FFFFCC">&nbsp;</td>
                              <td bgcolor="#FFFFCC">$135.00</td>
                              <td bgcolor="#FFFFCC"><div align="right"> 
                                  <input name="PROD_vendingCups_135.00" onChange="CalculateTotal(this.form)" type="text" id="vendingCups" size="6" />
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td class="code"><font color="#333333" size="-2">STIRWOOD</font></td>
                              <td class="description"><font color="#333333" size="-1">STIRRERS 
                                WOODEN</font></td>
                              <td>2000</td>
                              <td>&nbsp;</td>
                              <td>$12.90</td>
                              <td> <div align="right"> 
                                  <input name="PROD_stirWood_12.90" onChange="CalculateTotal(this.form)" type="text" id="stirWood" size="6" />
                                </div></td>
                            </tr>
                            <tr> 
                              <td height="23" bgcolor="#FFFFCC" class="code"><font color="#333333" size="-2">STIRPLAST</font></td>
                              <td bgcolor="#FFFFCC" class="description"><font color="#333333" size="-1">STIRRERS 
                                PLASTIC</font></td>
                              <td bgcolor="#FFFFCC">2000</td>
                              <td bgcolor="#FFFFCC">&nbsp;</td>
                              <td bgcolor="#FFFFCC">$36.90</td>
                              <td bgcolor="#FFFFCC"> <div align="right"> 
                                  <input name="PROD_stirPlastic_36.90" onChange="CalculateTotal(this.form)" type="text" id="stirPlastic" size="6" />
                                </div></td>
                            </tr>
                            <tr bgcolor="#FFFFFF"> 
                              <td height="38" colspan="6" class="code"> <div align="center">
                                  <table width="707" border="0" cellspacing="10">
                                    <tr> 
                                      <td width="685" height="134"> <table width="569" border="0" align="center" cellpadding="0" cellspacing="0">
                                          <tr> 
                                            <td height="31" colspan="4"><font color="#FF0000">All 
                                              fields marked * are mandatory. </font></td>
                                          </tr>
                                          <tr> 
                                            <td width="133"><div align="right">Company 
                                                Name<font color="#FF0000">*</font></div></td>
                                            <td width="165"> <div align="center">
                                                <input name="companyName" type="text" id="companyName" />
                                              </div></td>
                                            <td width="105"><div align="right">Order 
                                                Number<font color="#FF0000">*</font></div></td>
                                            <td width="166"> <div align="center">
                                                <input name="orderNumber" type="text" id="orderNumber2" />
                                              </div></td>
                                          </tr>
                                          <tr> 
                                            <td><div align="right">Contact Name<font color="#FF0000">*</font></div></td>
                                            <td> <div align="center">
                                                <input name="ContactName" type="text" id="ContactName" />
                                              </div></td>
                                            <td><div align="right">Phone Number<font color="#FF0000">*</font></div></td>
                                            <td> <div align="center">
                                                <input name="phoneNumber" type="text" id="phoneNumber2" />
                                              </div></td>
                                          </tr>
                                          <tr> 
                                            <td height="24"><div align="right">Delivery 
                                                Address<font color="#FF0000">*</font></div></td>
                                            <td> <div align="center">
                                                <input name="deliveryAddress" type="text" id="deliveryAddress3" />
                                              </div></td>
                                            <td> <div align="right"></div></td>
                                            <td> <div align="center">Total Cost 
                                                <input name="TOTAL" type="text" id="TOTAL" onFocus="this.form.elements[0].focus()" value="0" size="6" />
                                              </div></td>
                                          </tr>
                                          <tr>
                                            <td height="38">&nbsp;</td>
                                            <td>&nbsp;</td>
                                            <td>&nbsp;</td>
                                            <td><div align="center">
                                                <input name="Submit" type="submit" value="Confirm Order"/>
                                              </div></td>
                                          </tr>
                                        </table></td>
                                    </tr>
                                  </table>
                                </div></td>
                            </tr>
                          </table>
                          <div align="right"> </div></td>
                      </tr>
                    </table>
     
                    <div align="center"></div>
                  </form>
                </div>
                </div></td>
            <td width="1" id="rightborder">&nbsp;</td>
          </tr>
          <tr bgcolor="#000000"> 
            <td id="bl">&nbsp;</td>
            <td colspan="2" id="br"><div align="left"><font color="#999999">All content 
                C/font><font size="1">p<em>li</em></font> 
              </div></td>
          </tr>
        </tbody>
      </table>
    </div>
    </body></html>
    Last edited by JeremyW; Aug 7, 2007 at 03:00.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,157
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    else

    The script, as is:
    Code JavaScript:
    if (item_quantity >= 0) {
                    order_total += item_quantity * item_price
                }
    only tests for one condition. You can add other conditions with "else if" lines, but I think what you're after here is simply an "else" line. ie.
    Code JavaScript:
    if (item_quantity >= 0) {
                    order_total += item_quantity * item_price
                }
                else // empty, NULL, or 0
                {
                    // do stuff (alert?)
                }


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
  •