Goingpostal Posted February 20, 2008 Share Posted February 20, 2008 Hello everyone I am working on an online quoting system for my company and i have run into a few problems. first off the code: <HTML> <HEAD> <TITLE>Business Cards Instant Quote</TITLE> <script> function checkrequired(which){ var pass=true if (document.images){ for (i=0;i<which.length;i++){ var tempobj=which.elements[i] if (tempobj.name.substring(0,=="required"){ if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){ pass=false break } } } } if (!pass){ alert("One or more of the required elements are not completed. Please complete them, then submit again!") return false } else return true } </script> <style type="text/css"> <!-- --> </style> <link href="quoteSS.css" rel="stylesheet" type="text/css" /> </style> </HEAD> <!-- BEGIN PHP SCRIPTING --> <?php foreach ($_POST as $key => $value) { $$key = $value; } // Business Cards Colour switch ($Colour) { case "FCSS": $Colour_package = "Full Colour Single Sided"; $Cpackage = 0.00; break; case "FCDS": $Colour_package = "Full Colour Double Sided"; $Cpackage = 1.35; break; case "FCFBB": $Page_package = "Full Colour Front Black Back"; $Page = 4; break; case "FCDSSS": $Colour_package = "Full Colour Double Sided"; $Cpackage = 0.00; break; } // Stock switch ($Stock) { case "100GSM": $Stock_package = "100 GSM Laser"; $Spackage = 1.52; break; case "110GSM": $Stock_package = "110 GSM Laser"; $Spackage = 1.56; break; case "130GSMG": $Stock_package = "130 GSM Gloss"; $Spackage = 1.00; break; case "130GSMM": $Stock_package = "130 GSM Matt"; $Spackage = 1.00; break; case "150GSMG": $Stock_package = "150 GSM Gloss"; $Spackage = 1.00; break; case "150GSMM": $Stock_package = "150 GSM Matt"; $Spackage = 1.00; break; case "250GSMAG": $Stock_package = "250 GSM Artboard Gloss"; $Spackage = 1.00; break; case "250GSMAM": $Stock_package = "250 GSM Artboard Matt"; $Spackage = 1.35; break; case "250GSMAGL1": $Stock_package = "250 GSM Artboard Gloss Laminated 1 Side"; $Spackage = 1.35; break; case "250GSMAML1": $Stock_package = "250 GSM Artboard Matt Laminated 1 Side"; $Spackage = 1.00; break; case "250GSMAGL2": $Stock_package = "250 GSM Artboard Gloss Laminated 2 Sides"; $Spackage = 1.00; break; case "250GSMAML2": $Stock_package = "250 GSM Artboard Matt Laminated 2 Sides"; $Spackage = 1.00; break; case "250GSMIB": $Stock_package = "250 GSM Ivory Board"; $Spackage = 1.00; break; case "3ooGSMAG": $Stock_package = "300 GSM Artboard Gloss"; $Spackage = 1.00; break; case "300GSMAM": $Stock_package = "300 GSM Artboard Matt"; $Spackage = 1.00; break; case "340GSMIB": $Stock_package = "340 GSM Ivory Board"; $Spackage = 1.00; break; case "250GSMIB": $Stock_package = "250 GSM Ivory Board"; $Spackage = 1.00; break; case "130GSMGSS": $Stock_package = "130 GSM Gloss"; $Spackage = 0.78; break; case "130GSMMSS": $Stock_package = "130 GSM Matt"; $Spackage = 0.784; break; case "150GSMGSS": $Stock_package = "150 GSM Gloss"; $Spackage = 0.82; break; case "150GSMMSS": $Stock_package = "150 GSM Matt"; $Spackage = 0.82; break; } // Business Cards Coating switch ($Coating) { case "0": $Coating_package = "None"; $Coating = 0; break; case "MSS": $Coating_package = "Matt Single Sided"; $Coating = 1.00; break; case "MDS": $Coating_package = "Matt Double Sided"; $Coating = .55; break; case "GSS": $Coating_package = "Gloss Single Sided"; $Coating = 1.00; break; case "GDS": $Coating_package = "Gloss Double Sided"; $Coating = .55; break; } // Size switch ($Size) { case "DLSS": $Size_package = "DL"; $Size = 1.00; break; case "A5SS": $Size_package = "A5"; $Size = 0.55; break; case "A4SS": $Size_package = "A4"; $Size = 0.78; break; case "A3": $Size_package = "A3"; $Size = 0.55; break; } //Pages switch ($Page) { case "4": $Page_package = "4"; $Page = 4; break; case "6": $Page_package = "6"; $Page = 6; break; case "8": $Page_package = "8"; $Page = 0.78; break; case "10": $Page_package = "10"; $Page = 10; break; case "12": $Page_package = "12"; $Page = 1.52; break; case "14": $Page_package = "14"; $Page = 14; break; case "16": $Page_package = "16"; $Page = 16; break; case "18": $Page_package = "18"; $Page = 18; break; case "20": $Page_package = "20"; $Page = 20; break; case "22": $Page_package = "22"; $Page = 22; break; case "24": $Page_package = "24"; $Page = 24; break; } // Quantity switch ($Quantity) { case "250": $Quantity_package = "2000"; $Quantity = 250; $Quantity2 = 210; break; case "500": $Quantity_package = "1500"; $Quantity = 250; $Quantity2 = 140; break; case "1000": $Quantity_package = "2000"; $Quantity = 250; $Quantity2 = 210; break; case "1500": $Quantity_package = "1500"; $Quantity = 250; $Quantity2 = 140; break; case "2000": $Quantity_package = "2000"; $Quantity = 250; $Quantity2 = 210; break; case "500LET": $Quantity_package = "500"; $Quantity = 250; $Quantity2 = 0; break; case "1000LET": $Quantity_package = "1000"; $Quantity = 250; $Quantity2 = 70; break; case "1500LET": $Quantity_package = "1500"; $Quantity = 250; $Quantity2 = 140; break; case "2000LET": $Quantity_package = "2000"; $Quantity = 250; $Quantity2 = 210; break; case "250SS": $Quantity_package = "250"; $Quantityss = 250; break; case "500SS": $Quantity_package = "500"; $Quantityss = 500; $Quantity3 = 220; break; case "1000SS": $Quantity_package = "1000"; $Quantityss = 1000; $Quantity3 = 640; break; } // Cover for Saddle Stitched Books switch ($Cover) { case "250GSMAG": $Cover_package = "250 GSM Artboard Gloss"; $Covpackage = 0.78; break; case "250GSMAM": $Cover_package = "250 GSM Artboard Matt"; $Covpackage = 0.78; break; case "250GSMAGL1": $Cover_package = "250 GSM Artboard Gloss Laminated 1 Side"; $Covpackage = 1.18; $Covpackage2 = ; break; case "250GSMAML1": $Cover_package = "250 GSM Artboard Matt Laminated 1 Side"; $Covpackage = 1.18; $Covpackage2 = ; break; } // SET AUOTMATIC, UNIQUE QUOTE GENERATION VARIABLE $time = time(); $qn = rand(1, 99); $qn2 = rand(1,50000); $quote_num = $qn2 . ' ' . $qn; // SET ESTIMATED TIME OF COMPLETION VARIABLE $gst =(1.1); // CALCULATION OF QUOTE TOTAL VARIABLES FOLLOW $total2 =($Quantity2) + ($Quantityss) * ($Spackage + $Coating + $Cpackage + $Covpackage + $Page + $Size); $total3 = ($total2) - ($Quantity3); $total = ($total3) - ($Covpackage2); $total = number_format ($total, 2); // END CALCULATIONS FOR QUOTE TOTAL // START SCREEN PRINTING OF DATA // EMAIL QUOTE mail ('lxxxxxxxx.com.au', 'Instant Quote Generated', "Quote Number: $quote_num - Quote Total: $total --> Name: $requiredname Company: $requiredConame Telephone: $requiredPhone Email: $requiredEmail Type: $Type Cover: $Cover_package Pages: $Page_package Colour: $Colour_package Stock: $Stock_package Coating: $Coating_package Quantity: $Quantity_package ", 'From: '); ?> <div align="center"> <table width="580" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td height="58" colspan="4" valign="top"><table width="520" border="0" cellpadding="0" cellspacing="0"> <!--DWLayoutTable--> <tr> <td width="115" height="19"> </td> <td width="44"> </td> <td width="367"> </td> </tr> <form action="final.php" method="POST" onSubmit="return checkrequired(this)" language="JavaScript" name="FrontPage_Form1"> <tr> <td height="28" valign="middle"><span lang="en-us" class="style5"> Quote Number</span></td> <td colspan="2" align="left" valign="top"><label> <input name="requiredQuote" value="<? echo $quote_num ?>" type="text" class="style7" id="Quote" tabindex"5" size="40" readonly="true"> <span class="style7">*</span></label></td> </tr> <tr> <td height="22" valign="top"> <span class="style5">Total</span></td> <td colspan="2" align="left" valign="top"><label> <input name="requiredPrice" value="<? echo $total ?>" type="text" class="style7" id="total" tabindex"5" size="40" readonly="true"> <span class="style7">*</span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Type</span></td> <td colspan="2" align="left" valign="top"><label> <input name="Type" type="text" class="style5" id="Quote" tabindex value="<? echo $Type ?>""5" size="55" readonly="true"> <span class="style5"></span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Colour</span></td> <td colspan="2" align="left" valign="top"><label> <input name="Colour" type="text" class="style5" id="Quote" tabindex value="<? echo $Colour_package ?>""5" size="55" readonly="true"> <span class="style1"></span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Pages</span></td> <td colspan="2" align="left" valign="top"><label> <input name="Pages" type="text" class="style5" id="total" tabindex value="<? echo $Page_package ?>""5" size="55" readonly="true"> <span class="style1"></span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Cover</span></td> <td colspan="2" align="left" valign="top"><label> <input name="Cover" type="text" class="style5" id="total" tabindex value="<? echo $Cover_package ?>""5" size="55" readonly="true"> <span class="style1"></span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Stock</span></td> <td colspan="2" align="left" valign="top"><label> <input name="Stock" type="text" class="style5" id="total" tabindex value="<? echo $Stock_package ?>""5" size="55" readonly="true"> <span class="style1"></span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Coating</span></td> <td colspan="2" align="left" valign="top"><label> <input name="Coating" type="text" class="style5" id="Fname" tabindex="5" value="<? echo $Coating_package ?>" size="55" readonly="true"> <span class="style1"></span></label></td> </tr> <tr> <td height="22" valign="middle" class="style5"> Quantity</td> <td colspan="2" align="left" valign="top"><label> <input name="Quantity" type="text" class="style5" id="Fname" tabindex="5" value="<? echo $Quantity_package ?>" size="55" readonly="true"> <span class="style1"></span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Name</span></td> <td colspan="2" align="left" valign="top"><label> <input name="requiredname" type="text" class="style5" id="Coname" tabindex="2" value="<? echo $requiredname ?>" size="55"> <span class="style7">*</span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Company</span></td> <td colspan="2" align="left" valign="top"><label> <input name="requiredConame" type="text" class="style5" id="Coname" tabindex="2" value="<? echo $requiredConame ?>" size="55"> <span class="style7">*</span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Phone</span></td> <td colspan="2" align="left" valign="top"><label> <input name="requiredPhone" type="text" class="style5" id="Phone" tabindex="3" value="<? echo $requiredPhone ?>" size="55"> <span class="style7">*</span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Fax</span></td> <td colspan="2" align="left" valign="top"><label> <input name="Fax" type="text" class="style5" id="Fax" tabindex="4" size="55"> <span class="style1"></span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Email</span></td> <td colspan="2" align="left" valign="top"><label> <input name="requiredEmail" type="text" class="style5" id="Email" tabindex value="<? echo $requiredEmail ?>""5" size="55"> <span class="style7">*</span></label></td> </tr> <tr> <td height="22" valign="middle" class="style5"> Street Address</td> <td colspan="2" align="left" valign="top"><label> <input name="requiredAddress" type="text" class="style5" id="Address" tabindex"5" size="55"> <span class="style7">*</span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Suburb</span></td> <td colspan="2" align="left" valign="top"><label> <input name="requiredSuburb" type="text" class="style5" id="Suburb" tabindex"5" size="55"> <span class="style7">*</span></label></td> </tr> <tr> <td height="22" valign="middle"> <span class="style5">State</span></td> <td colspan="2" align="left" valign="top"> <select name="requiredState" class="style5" id="State" tabindex="8"> <option value="VIC" selected>VIC</option> <option value="ACT">ACT</option> <option value="NSW">NSW</option> <option value="NT">NT</option> <option value="QLD">QLD</option> <option value="SA">SA</option> <option value="TAS">TAS</option> <option value="WA">WA</option> </select> <span class="style7">*</span> </tr> <tr> <td height="22" valign="middle"> <span class="style5">Postcode</span></td> <td colspan="2" align="left" valign="top"><label> <input name="requiredPost" type="text" class="style5" id="Postcode" tabindex"5" size="55"> <span class="style7">*</span></label></td> </tr> <tr> <td height="31" valign="middle" class="style5"> Special Details</td> <td colspan="2" align="left" valign="top"><label> <textarea name="Details" cols="40" class="style5" id="Details"></textarea> <span class="style1"></span></label></td> </tr> <tr> <td height="49" colspan="3" align="center" valign="top" class="style5"> sdasdsadasdsad </tr> <tr> <td height="62" colspan="3" valign="top"> <p align="center"> <input type="submit" value="Order" name="Submit_Button" style="font-family: Arial; font-size: 10pt; color: #006600; font-weight: bold" tabindex="32"> </p></tr> <tr> <td height="24"> <td> <td valign="top"> <input name="Type" type="hidden" id="Type" value="Business Cards" /></tr> </form> </TABLE> </BODY> </HTML> Now the dilema: case "250GSMAGL1": $Cover_package = "250 GSM Artboard Gloss Laminated 1 Side"; $Covpackage = 1.18; $Covpackage2 = ; break; I need to have $Covpackage2 equal a different value depending on the quantity of the order: Example: If quantity = 500 then $Covpackage2 = 70 if quantity = 1000 then $Covpackage2 = 130 and so on How do I set this up???? regards Steven ??? ??? ??? Quote Link to comment https://forums.phpfreaks.com/topic/92202-changing-values-of-entered-strings/ Share on other sites More sharing options...
Psycho Posted February 20, 2008 Share Posted February 20, 2008 <?php case "250GSMAGL1": $Cover_package = "250 GSM Artboard Gloss Laminated 1 Side"; $Covpackage = 1.18; if ($quantity == 500) { $Covpackage2 = 70; } else if ($quantity == 1000) { $Covpackage2 = 130; } break; ?> Of course depending on your needs and requirements you could do something with arrays or functions. But, not enough information given to provide much else. Quote Link to comment https://forums.phpfreaks.com/topic/92202-changing-values-of-entered-strings/#findComment-472311 Share on other sites More sharing options...
Goingpostal Posted February 21, 2008 Author Share Posted February 21, 2008 Thank you very much!!!!!! regards Steven ;D Quote Link to comment https://forums.phpfreaks.com/topic/92202-changing-values-of-entered-strings/#findComment-472343 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.